HTML JS

HOW TO MOVE HTML ELEMENTS IN JAVASCRIPT

<div id="first">   <p>One</p>   <p>Two</p>   <p>Three</p> </div> <div id="second"></div>

HTML FOR THIS EXAMPLE

01

var source = document.getElementById("first");   var target = document.getElementById("second");   target.appendChild(source);

JS MOVE HTML ELEMENT

02

SOURCE & TARGET var source = document.getElementById("first");  var target = document.getElementById("second");

ALTERNATE METHOD

03

DUPLICATE CONTENT target.innerHTML += source.innerHTML; EMPTY SOURCE source.innerHTML = "";