//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; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter