Summary of the document node in JS

Source: Internet
Author: User
Tags processing instruction

The Document object is an instance of documenthtml and a property of the Window object, so you can access the Document object as a global object.

The child node of the document node can be documenttype,element,processinginstruction or comment. The ProcessingInstruction object can represent processing instructions. This infrequently used interface represents a processing instruction (or PI) in an XML document. The programmer who uses the HTML document does not encounter the ProcessingInstruction node, so there is no more introduction, DocumentType we can access his information through the DOCTYPE property. Comment, as a comment, said no more, just say the element.

1.html Elements and Body elements

Document.documentelement to get the HTML element, document.body to get the BODY element.

2. Documentation Information

Document.title gets the document title.

Document. The URL property contains the full URL of the page such as: {protocol}://{user name}:{password}@{hostname}:{port number}/{path}/{file}? Parameters

The Document.domain property includes only the domain name of the page.

The Document.referrer property is the page from which to jump to the current page.

3. Get elements

1) getElementById ();

2) getElementsByTagName ();

3) Getelementsbyname ();

4) Getelementsbyclassname ();

5) Queryselector (); Gets a single element, () can be a standard form of CSS selector compatible to CSS2.

6) Queryselectorall (); Gets the collection of elements, () can be the standard form of CSS selectors compatible to CSS2.

4. Special Collections

1) document.anchors: Contains all <a> elements of the document with the same characteristics.

2) Document.forms: Contains all the elements in the document, with the same result as document.getelementbytagname ("form").

3) Document.images: Contains all the elements in the document, with the same result as Document.getelementbytagname ("img").

4.document.links: Contains all the <a> elements in the document with the HREF attribute.

5. Document Writing

1) write (): Write as-is.

2) Writeln (): Adds a line break at the end of the string.

3) Open (): Opens the output stream of the Web page.

4) Close (): Closes the output stream of the Web page.

    

   

  

  

Summary of the document node in JS

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.