← Back to HTML DOM
Question 190
Move an Element Into Another Container
Move an Element Into Another Container
Move the paragraph with id="item" out of the div with id="source" and into the div with id="target". Appending an existing element to a new parent removes it from its old parent automatically. Platform-Provided HTML (READ-ONLY):<div id="source"><p id="item">Draggable</p></div><div id="target"></div>Steps: 1. Select both#targetand#item. 2. Calltarget.appendChild(item)— this moves the paragraph into the target.
Expected Output:
<div id="source"> </div> <div id="target"> <p id="item">Draggable</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.