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();
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-05-05 07:28:56 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|