CJCoding With Joseph
15per day

Create and Append New Element

Create 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>
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.