JS nodes are divided into three types:
ELEMENT Node 1
Attribute Node 2
Text Node 3
JS add element node:
innerHTML should be the most efficient way, of course, can also be created using document.createelement way, through AppendChild or Parentnode.insertbefore (newele,targetele ) to add ELEMENT nodes
JS Delete element node:
Parent.removechild (Ele)
JS Change or delete the attributes of an element node
SetAttribute RemoveAttribute
JS change the text value of the element node:
1: You can get the text node of the element node first, and then the text node has a property that is nodevalue, by changing the value of nodevalue to achieve the purpose of modifying the text of the element node
2: Through the element node InnerText property to achieve the purpose, but innertext will return the text including the child elements, and at the time of modification, if the element node contains child elements, will also be erased, outertext modification will delete the element itself
JS Gets the element node:
Get parent node: parentnode
Get first child node: FirstChild
Get Last child node: LastChild
Get previous sibling node: previoussibling
Get the latter sibling node: nextSibling
Get all types of child nodes: Childrennode returns all types of nodes, depending on whether the node's NodeType is a filter in all ELEMENT nodes
Get all child element nodes: Children only returns child element nodes, attribute nodes and text nodes do not return (IE8 will return comments as nodes)
JS to determine if a child node is included: Contains
JS Operation Dom of the increase and deletion check