move dom element to another parent

Solutions on MaxInterview for move dom element to another parent by the best coders in the world

showing results for - "move dom element to another parent"
Elyna
09 Feb 2017
1const newParent = document.getElementById('new-parent');
2const oldParent = document.getElementById('old-parent');
3
4while (oldParent.childNodes.length > 0) {
5    newParent.appendChild(oldParent.childNodes[0]);
6}