<ul id="birds"> <li>Orange-winged parrot</li> <li class="endangered">Philippine eagle</li> <li>Great white pelican</li> </ul> <script> const birds = document.querySelectorAll('li'); for (const bird of birds) { if (bird.matches('.endangered')) { console.log(`The ${bird.textContent} is endangered!`); } } </script>
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