Answers for "matches method in javascript"

0

matches method in javascript

<ul id="birds">
  <li>Orange-winged parrot</li>
  <li id="h" class="endangered">Philippine eagle</li>
  <li>Great white pelican</li>
</ul>

<script type="text/javascript">
  var birds = document.getElementsByTagName('li');

  for (var i = 0; i < birds.length; i++) {
    if (birds[i].matches('#h')) {
      console.log('The ' + birds[i].textContent + ' is endangered!');
    }
  }
</script>
Posted by: Guest on April-30-2021

Code answers related to "matches method in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language