Change innerHTML
easyQuestion 14Select the div with id="contentBox" and replace its innerHTML with a new heading and paragraph.
The new content should be:
- An <h2> with the text "Updated Content"
- A <p> with the text "This was added with innerHTML."
Platform-Provided HTML (READ-ONLY):
<div id="contentBox">
<p>Original content here.</p>
</div>Steps:
1. Use document.getElementById() to select the div
2. Use innerHTML to replace all content inside
3. Include both the <h2> and <p> tags in your innerHTML string
Expected output
<div id="contentBox"> <h2>Updated Content</h2> <p>This was added with innerHTML.</p> </div>
= newline. No newline after the last line.
Hints2 available
Sign in to use hintsTopics
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.