2024-05-05 13:22:44 -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');
|
|
|
|
console.assert(!(el === null), 'start exists');
|
|
|
|
|
|
|
|
var x = el.querySelector('.nonexistent');
|
|
|
|
console.assert(x === null, 'nonexistent element');
|
|
|
|
|
|
|
|
var y = el.querySelector('.b');
|
|
|
|
console.assert(!(y === null), 'Class b');
|
|
|
|
var inp = y.innerHTML;
|
|
|
|
console.assert(inp === 'This b class.', 'Class b.');
|
|
|
|
}
|
|
|
|
|
|
|
|
console.error('element.querySelector.html');
|
|
|
|
myFunction();
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-05-05 13:22:44 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|