matches method in javascript

Solutions on MaxInterview for matches method in javascript by the best coders in the world

showing results for - "matches method in javascript"
Cyprien
21 Jan 2020
1<ul id="birds">
2  <li>Orange-winged parrot</li>
3  <li id="h" class="endangered">Philippine eagle</li>
4  <li>Great white pelican</li>
5</ul>
6
7<script type="text/javascript">
8  var birds = document.getElementsByTagName('li');
9
10  for (var i = 0; i < birds.length; i++) {
11    if (birds[i].matches('#h')) {
12      console.log('The ' + birds[i].textContent + ' is endangered!');
13    }
14  }
15</script>
16