Web APIs

Element.nextElementSibling

Try the free JavaScript compiler

parentElement and nextElementSibling navigate element relationships; they can return null. Unlike nextSibling, nextElementSibling skips non-element nodes.

Formal Syntax & Structure

javascript syntaxjavascript
element.nextElementSibling

Return 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);
JavaScript Reference