1
2 // Get the element with id="myDIV" (a div), then get all elements inside div with class="example"
3var x = document.getElementById("myDIV").querySelectorAll(".example");
4
5
6 // Set the background color of the first element with class="example" (index 0) in div
7
8 x[0].style.backgroundColor = "red";