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