DOM element move

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gsb

    DOM element move

    I have created a div tag and appended it as a child to the document body.

    Obj=document.cr eateElement('DI V');
    Obj=document.bo dy.appendChild( Obj);

    Is there a way to move the object w/o deleting it and creating a new one?

    Maybe a remove and appendBefore or appendAfter?

    gsb


  • Lasse Reichstein Nielsen

    #2
    Re: DOM element move

    "gsb" <gsb@QWest.ne t> writes:
    [color=blue]
    > I have created a div tag and appended it as a child to the document body.
    >
    > Obj=document.cr eateElement('DI V');
    > Obj=document.bo dy.appendChild( Obj);[/color]

    No need to assign the return value of "appendChil d" to Obj. It returns
    the appended node, which is already the value of Obj.
    [color=blue]
    > Is there a way to move the object w/o deleting it and creating a new one?[/color]

    Any new insertion will move it. A DOM node can only occour once in a
    document, so inserting it a new place will remove it from its previous
    location.
    [color=blue]
    > Maybe a remove and appendBefore or appendAfter?[/color]

    No need to remove. Just insertBefore where you need it.
    someToBeParentN ode.insertBefor e(Obj,someNewSi bling);

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • DU

      #3
      Re: DOM element move

      gsb wrote:
      [color=blue]
      > I have created a div tag and appended it as a child to the document body.
      >
      > Obj=document.cr eateElement('DI V');
      > Obj=document.bo dy.appendChild( Obj);
      >
      > Is there a way to move the object w/o deleting it and creating a new one?
      >
      > Maybe a remove and appendBefore or appendAfter?
      >
      > gsb
      >
      >[/color]


      insertBefore:


      removeChild:


      DU

      Comment

      • L. 'Perfect' Gordon

        #4
        Re: DOM element move

        Create a new DIV where you want to move the current object then
        use 'oldDiv = Object.replaceC hild(newDiv, oldDiv)';

        I hope this has been helpful.

        --
        *************** *************** ******
        MUSIC24SEVEN
        Pioneers of the
        'Digital Entertainment Industry'

        *************** *************** ******
        "gsb" <gsb@QWest.ne t> wrote in message
        news:e8uAb.40$6 93.48549@news.u swest.net...[color=blue]
        > I have created a div tag and appended it as a child to the document body.
        >
        > Obj=document.cr eateElement('DI V');
        > Obj=document.bo dy.appendChild( Obj);
        >
        > Is there a way to move the object w/o deleting it and creating a new one?
        >
        > Maybe a remove and appendBefore or appendAfter?
        >
        > gsb
        >
        >[/color]


        Comment

        • gsb

          #5
          Re: DOM element move

          Thanks all.

          gsb


          Comment

          Working...