CJCoding With Joseph

Select First Paragraph by Tag

Use document.querySelector() with the tag name "p" to select the FIRST paragraph on the page and change its text to "Updated first". Leave the second paragraph unchanged.

Platform-Provided HTML (READ-ONLY):
<div id="c">
  <p>First</p>
  <p>Second</p>
</div>

Steps:
1. Call document.querySelector("p") — it returns the first matching element.
2. Set that element's textContent to "Updated first".

Expected Output:

<div id="c">
  <p>Updated first</p>
  <p>Second</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.