CJCoding With Joseph
15free / daySign inCreate account

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>

= newline. No newline after the last line.

Hints2 available
Topics:
HTML DOM
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.