Skip to content

Instantly share code, notes, and snippets.

@crongro
Created October 12, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crongro/b52354019ef395135e7c to your computer and use it in GitHub Desktop.
Save crongro/b52354019ef395135e7c to your computer and use it in GitHub Desktop.
A Pen by younjisu.
<div id="first"><span>first span</span></div>
<div id="two"></div>
var elspan = document.querySelector("#first span");
var eltwo = document.querySelector("#two");
//1. clone (copy)
//var _c = elspan.cloneNode(true);
//eltwo.appendChild(_c);
//2. appendChild (move)
//eltwo.appendChild(elspan);
//3. importNode (for other Document(iframe))
var _i = document.importNode(elspan, true);
eltwo.appendChild(_i);
#first{
width : 100px;
height : 50px;
outline : 1px solid green;
}
#two {
width : 100px;
height : 50px;
outline : 1px solid red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment