Re: Moving DOM Nodes

RobG
Wed, 19 Sep 2007 21:19:52 -0000

On Sep 19, 10:20 pm, Frederic JECKER
<f.jec...-Q24KPKXrcE4YLvoOxY5KjA@public.gmane.org>
wrote:
> Hi,
> After further working/searching I found a solution, below an example:

But it''s not as good as the "solution" I offered. :-)

>
>  var tomove=$(div);
>         if(tomove.parentNode!=null &&
tomove.parentNode.id!=''glassPane''){
>             var clone=tomove.cloneNode(true);
>             $(''glassPane'').appendChild(clone);
>             var objBody =
document.getElementsByTagName(''body'').item(0);
>             objBody.removeChild(tomove);

There is no need to clone the node, add the clone, then remove the
original.  Just move the node to where you want it:

             $(''glassPane'').appendChild(tomove);

That''s it.