The DOM (Document Object model) depicts a hierarchical tree of nodes.
1.1 Node type
The node type can be divided into 12 types, all of which inherit from node type and share the same basic properties and methods. The main node types are the element node, the attribute node (attribute node), and the text node. To understand the details of a node, you can use NodeName and nodevalue two properties, and NodeType can determine the type of the node.
Where the element node NodeType is 1, the attribute node NodeType is 2, and the text node NodeType is 3.
if (Somenode.nodetype = = node.element_node) { alert (' This is an element node ');}
Because of the particularity of IE, so the above code will appear error, in order to ensure the compatibility of the browser, so it is best to use the following method to determine its node type. if (somenode.nodetype = = 1) { alert (' This is an element node ');}
In each node, it has a childnodes property that holds the NodeList object ( Note: NodeList can automatically reflect changes in the DOM structure, which is dynamic.) ). Similarly, each node has a ParentNode property that points to the parent node of the text. All lists in the childnodes of a node have the same parent node. So in a node, there are several ways to manipulate nodes, represented by a graph.
Note:firstelementchild, nextelementsibling,
JavaScript series (ii) DOM