Home > Article > Web Front-end > The nearest related node access method of a node in javascript_javascript skills
In JavaScript, for each node in the document, there is
parentNode - parent node
firstChild - the first child node
lastChild - the last child node
previousSibling - the immediately preceding sibling node
nextSibling - the immediately following sibling node
Five related nodes, these nodes may not exist , is null. For example, document does not contain parent nodes, and text node (TextNode) does not contain child nodes.
This allows you to take a short trip and visit some related nodes of the current node.
In addition, there are childNode[] (contains all child nodes) and children[] (contains only child nodes of type element node, excluding text node textNode).