<!DOCTYPE html>
<html>
<style>
.example {
border: 1px solid black;
margin: 5px;
}
</style>
<body>
<h1>The Document Object</h1>
<h2>The querySelectorAll() Method</h2>
<p>Change the background color of all elements with class="example":</p>
<div class="example">
A div with class="example"
</div>
<div class="example">
A div with class="example"
</div>
<p class="example">This is a p element with class="example".</p>
<p>This is a <span class="example">span</span> element with class="example" inside another p element.</p>
<script>
const nodeList = document.querySelectorAll(".example");
for (i = 0; i < nodeList.length; i++) {
nodeList[i].style.backgroundColor = "red";
}
</script>
</body>
</html>