2024-04-12 15:27:06 -04:00
|
|
|
<ul id="birds">
|
|
|
|
<li>Orange-winged parrot</li>
|
|
|
|
<li class="endangered">Philippine eagle</li>
|
|
|
|
<li>Great white pelican</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
2024-05-07 10:36:02 -04:00
|
|
|
console.error('element.matches.html');
|
2024-04-12 15:27:06 -04:00
|
|
|
|
|
|
|
var birds = document.getElementsByTagName('li');
|
2024-05-05 13:54:12 -04:00
|
|
|
var ch = false;
|
2024-05-07 10:36:02 -04:00
|
|
|
console.assert(birds.length === 3, '3');
|
2024-04-12 15:27:06 -04:00
|
|
|
|
|
|
|
for (var i = 0; i < birds.length; i++) {
|
2024-05-07 10:36:02 -04:00
|
|
|
if (birds.item(i).matches('.endangered')) {
|
|
|
|
console.assert(birds.item(i).innerHTML === 'Philippine eagle', birds.item(i).innerHTML);
|
2024-05-05 13:54:12 -04:00
|
|
|
ch = true;
|
2024-04-12 15:27:06 -04:00
|
|
|
}
|
|
|
|
}
|
2024-05-05 13:54:12 -04:00
|
|
|
console.assert(ch, 'was matched');
|
2024-05-07 10:36:02 -04:00
|
|
|
// birds = document.querySelectorAll('li');
|
2024-05-06 12:40:02 -04:00
|
|
|
|
|
|
|
ch = false;
|
2024-05-06 15:07:27 -04:00
|
|
|
// var counter = 0;
|
|
|
|
// birds.forEach(function(b) {
|
|
|
|
// counter++;
|
|
|
|
// });
|
|
|
|
// console.assert(counter === 3, 'Three');
|
2024-04-12 15:27:06 -04:00
|
|
|
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-04-12 15:27:06 -04:00
|
|
|
|
|
|
|
</script>
|