Javascript-Node Properties detailed
Each component in the dom,html document is a node.
This is what the DOM provides:
The entire document is a document node
Each HTML tag is an element node
Text that is contained in an HTML element is a text node
Each HTML attribute is an attribute node
Comments belong to note nodes
First, how to get the node reference
1. Old how to get node references
getElementById ()
Getelementbytagname ()
Getelementbyname ()
*******************************************
Disadvantage:
1. Wasting memory
2. Not strong logic
*******************************************
2. Get a reference to a node by the node relationship property
Object. parentnode get a reference to the parent node
Object. ChildNodes gets the collection of child nodes
Object. FirstChild get the first child node
Object. LastChild Gets the first child node \
Object. nextSibling get a reference to the next sibling node
Object. PreviousSibling get a reference to the previous sibling node
****************************************************************
Disadvantage: Poor compatibility.
****************************************************************
Second, node information (attributes)
Node type node name node value
NodeType (value) NodeName NodeValue
Element node 1 label name null
Attribute Node 2 Property Name property value
Text Node 3 #text text
Note Node 8 #comment The text of the comment
Document node 9 #document null
Third, the method of compatibility
JavaScript Learning Notes--node