If you not use -
in id's names then you can do this
oldParent.id='xxx';_x000D_
newParent.id='oldParent';_x000D_
xxx.id='newParent';_x000D_
oldParent.parentNode.insertBefore(oldParent,newParent);
_x000D_
#newParent { color: red }
_x000D_
<div id="oldParent">_x000D_
<span>Foo</span>_x000D_
<b>Bar</b>_x000D_
Hello World_x000D_
</div>_x000D_
<div id="newParent"></div>
_x000D_