QP School

Full Version: Select elements by CSS selector in JavaScript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The HTML part between the <body></body> tags looks like this:

Code:
<!-- Selecting elements by CSS selector -->

<div id="container">
  <p class="note">This is a note</p>
  <p class="note">This is another note</p>
  <p class="error">An error message</p>
</div>

The JavaScript part of the code looks like this:

Code:
// Selecting elements by CSS selector

let container = document.querySelector("#container");

document.write(container);