The first step in manipulating an HTML document is to get a reference to the document element, where each element is a node in the DOM, and all the elements form a node tree in the DOM.
The method used to get the element node definition is defined in the HTMLDocument interface, the Window.document method is used to implement the interface, and the common methods and properties of its definition are as follows:
| Property or method |
return value type |
Description |
| [Getter] |
Any type |
Gets all element nodes based on the element's Name property |
| All |
Htmlallcollection |
A collection of all the elements in the document that are deprecated |
| Body |
HtmlElement |
Get <body> element node |
| Head |
Htmlheadelement |
Get |
| Images |
Htmlcollection |
Get all ELEMENT nodes |
| Embeds |
Htmlcollection |
Get all <embed> ELEMENT nodes |
| Plugins |
Htmlcollection |
Equivalent to the Embeds property |
| Links |
Htmlcollection |
Gets all <a> and <area> element nodes with the href attribute |
| Forms |
Htmlcollection |
Get all <form> ELEMENT nodes |
| Scripts |
Htmlcollection |
Get all <script> ELEMENT nodes |
| Getelementsbyname () |
NodeList |
Gets all element nodes based on the element's Name property |
| Getelementsbyclassname () |
NodeList |
Get all ELEMENT nodes based on the class property of the element |
In addition, the HTMLDocument interface inherits the document interface of the core DOM, inheriting the following properties and methods:
| Property or method |
return value type |
Description |
| DocumentElement |
Element |
Get the root element of XML or HTML, |
| getElementById () |
Element |
Gets the specified element based on the ID property value |
| getElementsByTagName () |
NodeList |
Get all element nodes based on element name |
| Getelementsbytagnamens () |
NodeList |
Gets all element nodes based on the element name of the specified namespace |
Original starting: Http://www.ido321.com/1315.html
‘
Next: Dom Notes (ii): node interface
Dom Note (i): HTMLDocument interface