dom is the standard for how to get, modify, add, or remove HTML elements, and here's how to do HTML DOM node operations, and interested friends can refer to the following
The HTML DOM is the standard for how to get, modify, add, or delete HTML elements. In the HTML DOM, all things are nodes. The DOM is the HTML that is treated as a node tree. All content in an HTML document is a node: according to the HTML DOM standard of the World wide file the entire document is a document node each HTML element is an element node the text within the HTML element is a text section Points Each HTML attribute is an attribute node comment is an annotation node HTML DOM that makes an HTML document a tree structure. This structure is called the node tree: HTML DOM subtree instance ct_htmltree.gif through the HTML DOM, all nodes in the tree are accessible through JavaScript. All HTML elements (nodes) can be modified, or nodes can be created or deleted. All HTML elements are defined as objects, while programming interfaces are object methods and object properties. One: Get element node method: 1.var node = document.getElementById ("nodeId"); 2.var nodelist = Docum Ent.getelementsbyclassname ("Nodeclassname"); 3.var nodelist = document.getElementsByTagName (" Nodetagname "); II: Get to the element node what we can do with him: 1. The operation of oneself. 2. Operation of child nodes. 3. The operation of the sibling node. 4. Operation of the parent node 2.1. Delete itself: Node.parentNode.removeChild (node); 2.2. Determine if there are child nodes: var Boolean = Node.haschildnodes (); Get list of child nodes: var childlist = node.childnodes; Get node element type: var NodeType = Node.nodetype; var nodename = node.nodename; Delete child nodes. Node.removechild (Childnode); Inserts a child node at the end of the child node: Node.appendchild (Childnode); does not insert a child node in the child node: Node.insertbefore (Childnode); replaces B node with A node: Node.replacechild (a,b); 2.3. Node.nextsibling gets the next sibling node Node.previoussibling Gets the neighboring last sibling node 2.4. Get parent Node node.parentnode