element traversal properties
DOM properties such as children, firstElementChild and nextElementSibling that move between elements while skipping text and comment nodes.
In more detail
The older firstChild and nextSibling return any node, including the whitespace text between tags, which surprises many beginners. The element versions give you only elements.
Related terms
- DOM node — One object in the DOM tree, such as an element, a run of text or a comment.
- descendant — Any node below a given node in the DOM tree: its children, their children and so on.
- sibling — A node that shares the same parent as another node in the DOM tree.
- whitespace — Characters that show as blank space, such as spaces, tabs and line breaks.
Taught in
- Modern DOM Querying: querySelector, closest And matches — Frontend Architecture & Web Platform