<div id="div-01">Here is div-01</div>
<div id="div-02">Here is div-02</div>Element: nextElementSibling property / notebook
Element: nextElementSibling property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
let el = document.getElementById("div-01").nextElementSibling;
console.log("Siblings of div-01:");
while (el) {
console.log(el.nodeName);
el = el.nextElementSibling;
}