Access sub-node ChildNodes
Accesses the list of all child nodes under the selected element node, the returned value can be considered an array, and he has the length property.
Grammar:
Elementnode.childnodes
Attention:
If the selected node has no child nodes, the property returns a NodeList that does not contain a node.
Let's take a look at the following code:
Operation Result:
Ie:
Number of UL sub-nodes: 3 node Type: 1
Other browsers:
Number of UL sub-nodes: 7 node Type: 3
Attention:
1. IE full range, Firefox, Chrome, opera, safari compatibility issues
2. The whitespace between the nodes, in Firefox, Chrome, opera, Safari browser is the text node, so IE is 3, the other browser is 7, as shown:
If you change the code to this:
<ul><li>javascript</li><li>jQuery</li><li>PHP</li></ul>
Run Result: (IE and other browser results are the same)
Number of UL sub-nodes: 3 node Type: 1
Javascript--dom Access sub-node ChildNodes