Web APIs
Element.nextElementSibling
parentElement and nextElementSibling navigate element relationships; they can return null. Unlike nextSibling, nextElementSibling skips non-element nodes.
Formal Syntax & Structure
javascript syntaxjavascript
element.nextElementSiblingReturn Value
Element | null
Next element sibling or null.
Working Example
Example Snippetjavascript
const r=document.createElement("div");const a=document.createElement("i"),b=document.createElement("b");r.append(a," ",b);console.log(a.nextElementSibling===b,a.parentElement===r);