nextSibling property
The read-only nextSibling
property of the Node
interface
returns the node immediately following the specified one in their
parent's Node.childNodes
, or returns null
if the specified node is the last child in the parent element.
Note: Browsers insert
Text
nodes into a document to represent whitespace in the source markup. Therefore a node obtained, for example, usingNode.firstChild
orNode.previousSibling
may refer to a whitespace text node rather than the actual element the author intended to get.The article Whitespace in the DOM contains more information about this behavior.
You can use
Element.nextElementSibling
to obtain the next element skipping any whitespace nodes, other between-element text, or comments.To navigate the opposite way through the child nodes list use Node.previousSibling.
Implementation
external Node? get nextSibling;