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

33 lines
706 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">
console.error('element.matches');
var birds = document.getElementsByTagName('li');
2024-05-05 13:54:12 -04:00
var ch = false;
2024-04-12 15:27:06 -04:00
for (var i = 0; i < birds.length; i++) {
if (birds[i].matches('.endangered')) {
2024-05-05 13:54:12 -04:00
console.assert(birds[i].innerHTML === 'Philippine eagle', birds[i].innerHTML);
ch = true;
2024-04-12 15:27:06 -04:00
}
}
2024-05-05 13:54:12 -04:00
console.assert(ch, 'was matched');
birds = document.querySelectorAll('li');
ch = false;
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>