Create and Append New Element
mediumQuestion 15Create a new paragraph element with the text "This paragraph was created with JavaScript!" and append it to the div with id="container".
Platform-Provided HTML (READ-ONLY):
<div id="container">
<p>Existing paragraph.</p>
</div>Steps:
1. Use document.createElement() to create a new <p> element
2. Set its textContent to "This paragraph was created with JavaScript!"
3. Use document.getElementById() to select the container
4. Use appendChild() to add the new paragraph to the container
Expected output
<div id="container"> <p>Existing paragraph.</p> <p>This paragraph was created with JavaScript!</p> </div>
= newline. No newline after the last line.
Hints4 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.