JSFiddle - React, Tailwind, and code Playground

by Ramya Ranganathan

HTML

<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

var moveMe = document.getElementById("moveMe");
var newParent = document.getElementById("newParent");
newParent.appendChild(moveMe);