2024-05-05 07:28:56 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<p class="a">Class a.</p>
|
|
|
|
<p class="b">Class b.</p>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function myFunction() {
|
|
|
|
var x = document.querySelector('.nonexistent');
|
|
|
|
console.assert(x === null, 'nonexistent element');
|
|
|
|
|
|
|
|
var y = document.querySelector('.b');
|
|
|
|
console.assert(!(y === null), 'Class b');
|
2024-05-05 10:58:10 -04:00
|
|
|
var inp = y.innerHTML;
|
|
|
|
console.assert(inp === 'Class b.', 'Class b.');
|
2024-05-05 07:28:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
console.error('document.querySelector.html');
|
|
|
|
myFunction();
|
|
|
|
console.exit(0);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|