In JavaScript, you can use the childnodes attribute to return an array containing all the subnodes of a given element node, as shown in figureCodeAs shown in:
Flat view printing?
03 |
< Li Title = "First text" > First </ Li > |
04 |
< Li Title = "Second paragraph" > Second </ Li > |
06 |
< Script Type = "Text/JavaScript" > |
07 |
VaR attr_p = Document. getelementbyid ("action "); |
08 |
Alert (attr_p.childnodes [1]. childnodes [0]. nodevalue ); |
You can use... Childnodes [1]. childnodes [0]. nodevalue... Childnodes [1]. firstchild. nodevalue can also find the first Li text node,
Conclusion childnodes [0] is equivalent to firstchild. whenever and wherever it is necessary to access the first element of the childnodes [] array, we can write it as firstchild, dom also provides a corresponding lastchild attribute.
Note that you can use the nodetype attribute to determine the node type for the FF space node until the element node is found.