The first hair of the traversal DOM tree given by the JS Official document is:
Parent Node-ele.parentnode
Child node-ele.childnode
First child node-firstchild
Last child node-lastchild
Previous sibling node-previoussibling
Next sibling node-nextsibling
To get an element from a property:
document.getElementById (); -Through ID
document.getelementsby** ()-Returns an array via another property.
But there is one problem: most of the time you traverse a DOM tree to get an element node rather than a text node
So you can use the method to get the desired element node directly:
Parent Node-ele.parentelementnode
Child node-ele.children
First child element node-firstelementchild
Last child element node-lastelementchild
Last sibling element node-previouselementsibling
Next sibling element node-nextelementsibling
So suddenly feel Bang bang ~ ~ But the good things IE are not compatible AH (again damned IE)
These methods are not compatible with the IE browsers below IE8 ...
Only Ele.children this one is compatible in IE8 but it also treats annotations as element nodes.
So, in short, in any case in IE use or be careful for the wonderful ~ ~ ~