① 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
<Input type = "hidden" id = "hello8" name = "category_id" value = "2"/>
<Select id = "category_id" onchange = "al ();">
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> <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
<Input type = text name = "content" id = "content">
③ There are two methods to obtain html tags: ID and name.
The name attribute is mainly used for the input mark in the form.