<h3>Practice Set #1, Week 8, Modifying the DOM</h3>
<p>We're going to move a DOM element from one location to another in this HTML document. Your task is to remove the element <code>#moveMe</code> from <code>#oldParent</code> and add it to the element <code>#newParent</code>.</p>
<p>Hint: this may require fewer steps than you think. Read the first paragraph of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Node.appendChild" target="_blank">MDN Node.appendChild() docs</a> for guidance.</p>
<b>Dogs</b>
<ol id="oldParent">
<li>Simon</li>
<li id="moveMe">Baxter</li>
<li>Ripley</li>
</ol>
<b>Famous Dogs</b>
<ol id="newParent">
<li>Lassie</li>
<li>Astro</li>
<li>Scooby</li>
</ol>
JavaScript
// your solution here
oldParent.removeChild(moveMe);
document.body.appendChild(moveMe);
//var newParent.createElement("moveMe");
//var newParent = document.createElement("moveMe");
//document.body.appendChild(moveMe);
// some suggested steps:
// 1) Get the elements for the ids 'moveMe', 'oldParent', and 'newParent' and assign them to variables
// (You actually will not need all three of these, you only need two. Part of the task is to figure out which two. Refer to the MDN docs linked in the HTML for guidance.)
// 2) Now, use appendChild() to make the move happen.
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.