I am writing a script that should move the node wrapping element on the page. I find that when I do this, I delete the previously wrapped children. How to disable node children so that I can move the node parent to another location?
I thought something like this:
var parg = document.getElementById("blah");
if (parg.hasChildNodes())
{
var children = parg.childNodes;
while (children.length > 0)
{
parg.insertBefore(parg.firstChild);
parg.removeChild(parg.firstChild);
};
};
The line I assume is a problem of the "insertBefore" logic.
source
share