Select all next sibling elements

PHOTO EMBED

Tue Jan 11 2022 09:11:22 GMT+0000 (UTC)

Saved by @Kristi #css #html

//HTML
<ul id="menu">
    <li>Home</li>
    <li>Products</li>
    <li class="current">Customer Support</li>
    <li>Careers</li>
    <li>Investors</li>
    <li>News</li>
    <li>About Us</li>
</ul>

//JS
let current = document.querySelector('.current');
let nextSibling = current.nextElementSibling;

while(nextSibling) {
    console.log(nextSibling);
    nextSibling = nextSibling.nextElementSibling;
}
content_copyCOPY

javascripttutorial.net/javascript-dom/javascript-siblings/