Re: Moving DOM Nodes

RobG
Wed, 19 Sep 2007 23:39:25 -0000

On Sep 20, 7:19 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org>
wrote:
> 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''){

Thinking about that a little further, there is not much value in the
first test - the only element that doesn''t have a parentNode is the
document, which can''t be retrieved by $(someId).

Consider:

  var tomove = $(div);
  var target = $(''glassPane'');
  if (tomove.parentNode != target) target.appendChild(tomove);