Reference
JavaScript native DOM manipulation methods
JavaScript native DOM manipulation methods
First Category: node lookup related methods and properties
document/the parent node. getElementById ()
document/the parent node. getElementsByTagName ()
document/the parent node. getelementsbyname () //IE8 The following is not compatible
Called: Dom0-level method
. Gets the attributes of the element (common) getattribute ()
. Set the attributes of an element (common) setAttribute ()
In addition, the following methods are available in the DOM extension:
Queryselector ()
Queryselectorall ()
Matchesselector ()
The above method receives a CSS selector pair
Related references
Consider the related hierarchy relationship properties of whitespace characters
. Access child node properties DOM object. ChildNodes; Note that there are so-called "blank items" issues due to compatibility issues
Example:
var childnode = document.getElementsByTagName ("ul") [0].childnodes;
. Accessing the parent node parentnode
JavaScript DOM Object Common Properties
. innerHtml Dom object. innerHtml
. NodeType
. NodeName
. Offsetwidth offsetheight
. scorllheight
Document.documentElement.offsetWidth | | Document.body.offsetwidth;document.documentelement.offsetheight;
Class II: Dynamic Operation node related methods
. Create element node createelement () or document.createelement ()
. Create a text node createTextNode ()
. Add child node: parent element. appendchild ()
. Insert new node: parent element. insertbefore (Newnode,relnode)
. Replace node: parent element. replacechild (Newnode,oldnode)
. Delete node: parent element. removechild (node)
. Clone node: node. CloneNode () passed in true parameter represents deep clone, otherwise shallow clone
Javascript-dom notes