CJCoding With Joseph
15per day

Query Selector by Class

Use querySelector() to select the first element with class "highlight" and change its text content to "Highlighted Text".

Platform-Provided HTML (READ-ONLY):
<div id="content">
  <p class="highlight">First paragraph</p>
  <p class="highlight">Second paragraph</p>
</div>

Steps:
1. Use document.querySelector() with a class selector (".highlight")
2. Change the selected element's textContent to "Highlighted Text"
3. Note: querySelector() only selects the FIRST matching element

Expected Output:

<div id="content">
  <p class="highlight">Highlighted Text</p>
  <p class="highlight">Second paragraph</p>
</div>
Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.