DOM note (1): HTMLDocument interface, domhtmldocument

Source: Internet
Author: User

DOM note (1): HTMLDocument interface, domhtmldocument

The first step in operations on HTML documents is to obtain reference to document elements. Each element is a node in the DOM, and all elements constitute a node tree in the DOM.

The parameter used to obtain the Element Definition is defined in the htmldocumentinterface. The parameter Doc ument method is used to implement the interface. The commonly used methods and attributes are defined as follows:

 

Attribute or Method Return Value Type Description
[Getter] Any Type Obtains all element Nodes Based on the element name attribute.
All HTMLAllCollection A set composed of all elements in the document, which is not recommended
Body HTMLElement Obtain the <body> element node
Head HTMLHeadElement Obtain the
Images HTMLCollection Obtain all element nodes
Embeds HTMLCollection Obtain all <embed> element nodes
Plugins HTMLCollection Equivalent to embeds attributes
Links HTMLCollection Obtain all <a> and <area> element nodes with href attributes.
Forms HTMLCollection Obtain all <form> element nodes
Scripts HTMLCollection Obtain all <script> element nodes
GetElementsByName () NodeList Obtains all element Nodes Based on the element name attribute.
GetElementsByClassName () NodeList Obtains all element nodes based on the class attribute of the element.

In addition, the HTMLDocument interface inherits the Document Interface of Core DOM. The inherited attributes and methods are as follows:

Attribute or Method Return Value Type Description
DocumentElement Element Get the root element of xml or html. in html, that is,
GetElementById () Element Obtains the specified Element Based on the ID attribute value.
GetElementsByTagName () NodeList Retrieve all element nodes by element name
GetElementsByTagNameNS () NodeList Obtains all element Nodes Based on the specified namespace element name.
First: http://www.ido321.com/1315.html
'
Next article: DOM note (2): Node interface

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.