When is document and document. all used?
<Body> <p id = "aa"> 123456 </p> <input type = "button" value = "An error occurred while using document" onclick = "alert (document. aa. innerText); "/> <input type =" button "value =" document. "onclick =" alert (document. all. aa. innerText); "/> </body>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
If the name attribute is set in the html Tag corresponding to a, form object, image object, and applet object, its value will be used as the property name of the document Object, it is used to reference the corresponding object. Other objects are not allowed.
In addition, if input is used as a child element of form, inputName or document is used directly. it is incorrect to reference this object using inputName. formName must be used. inputName reference. Otherwise, you can use inputName to reference it.
In addition, we should note that many elements that are commonly used do not have a name.
If you want to reference an element with an id, you can only use Id or document. getElementById, document. all. id to reference it.
However, elements like this, such...
Available
Linkid. href;
Linkname. href;
Document. all. linkid. href;
Document. all. linkname. href;
Document. getElementById ("linkid"). href;
Document. getElementsByName ("linkname") [0]. href to reference
All is a set that contains all html objects. You can write a program to access all objects. Like this: