2024-05-06 10:31:53 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<p class="a">Class a.</p>
|
|
|
|
<p class="b">Class b.</p>
|
|
|
|
<p id="start">
|
|
|
|
<b class="a">This a class.</b>
|
|
|
|
<b class="b">This b class.</b>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function myFunction() {
|
|
|
|
var el = document.getElementById('start');
|
|
|
|
var x = el.querySelectorAll('.nonexistent');
|
|
|
|
console.assert(x.length === 0, 'nonexistent element');
|
|
|
|
|
|
|
|
var y = el.querySelectorAll('.b');
|
|
|
|
console.assert(y.length === 1, 'b class b.');
|
2024-07-23 13:01:50 -04:00
|
|
|
|
|
|
|
console.assert(y.item(0).innerText === 'This b class.', 'b class');
|
|
|
|
|
2024-05-06 10:31:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
console.error('element.querySelectorAll.html');
|
|
|
|
myFunction();
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-05-06 10:31:53 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|