Document. getElementById details ① document. getElementById sometimes misses the name, which is said to be a BUG in IE;
Http://community.csdn.net/Expert/topic/4223/4223888.xml? Temp =. 1947443.
The page contains
Program code
One is name = "category_id" and the other is id = "category_id"Use document. getElementById to get the second one. However, the first name = category_id is obtained.In IE, getElementById does not capture the id first, but first finds the object with the same name...Two forms. Each form has two textbox. the textbox in the two forms has the same name, but the IDs are different...So there is no problem in Firefox.The following code verifies the result. <HTML> <HEAD> <TITLE> getElementById </TITLE> </HEAD> <script language = "JavaScript"> <! -- Function chkacc () {alert (document. getElementById ("tbxuid1 "). value); alert (document. getElementById ("tbxpwd1 "). value); alert (document. getElementById ("tbxuid "). value); alert (document. getElementById ("tbxpwd "). value);} // --> SCRIPT <BODY> </HTML
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
② Use getElementbyId in javascript
The elements in the web page must have the id attribute to be obtained through this method, for example
③ There are two methods to obtain html tags: ID and name.
The name attribute is mainly used for the input mark in the form.