Node: appendChild() method
DOM API
<div id="content"></div>
<script>
const content = document.getElementById("content");
const h1=document.createElement("h1");
h1.textContent="Title h1";
content.appendChild(h1);
</script><body>
<div id="content">
<h1>Title h1</h1>
</div>
<script>
const copied = document.createElement('div');
document.body.appendChild(copied);
const content = document.getElementById("content");
while(content.childNodes.length > 0){
copied.appendChild(content.childNodes[0]);
}
</script>
</body>Last updated