<
Body
>
<
Div
id
= "aa"
>
123456
Div
>
<
INPUT
Type
= "Button"
Value
= "Here with Document is wrong"
Onclick
= "Alert (Document.aa.innertext);"
/>
<
Br
/>
<
INPUT
Type
= "Button"
Value
= "Here you don't have an error with Document.all"
Onclick
= "Alert (Document.all.aa.innertext);"
/>
Body
>
Run the above code.
If the NAME property is set in the HTML tag corresponding to the A, FORM object, the image object, the Applet object, which will be used as the properties name of the Document object, used to reference the corresponding object, other objects can not . In addition, if INPUT, if you use InputName or Document.InputName to reference this object directly, you must use the forMname.inputName reference, otherwise you can use the inputName to reference. Don't pay attention to there are many usage There is no Name element. If you want to reference an element with ID, you can only use ID or document.getlementByid, Document.all.id, but like this element, it is like ...... can use linkId.href; linkname.href; document.all.linkid.href; document.all.linkname.href; Document.getElementByid ("linkid"). href; document.getlementsByname ("linkname") [0] .href to reference
All is a collection that contains a collection of all HTML objects, writes a program, and you can access all objects. Like this: