1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-20 01:46:15 -04:00
elinks/test/ecmascript/assert/element.matches.html

34 lines
781 B
HTML
Raw Normal View History

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');
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
console.exit(0);
</script>