When does document and document. all use basic knowledge?

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.