Results 1 to 2 of 2

Thread: prependChild instead of appendChild

  1. #1

    prependChild instead of appendChild

    Let's say I already have code to create DIV's with the CSS "float:left" property. I want to add these floating DIV's to the beginning of the container DIV instead of to the end because there's a "clear:both" line break that will make the container expand as I insert new floating DIV's.

    Code:
    <div id="container">
       <br class="clear" />
    </div>
    Is there such a function like this fake "prependChild" I made up?

    PHP Code:
    var container document.getElementById("container");
    cointainer.prependChild(floatDiv1);
    cointainer.prependChild(floatDiv2);
    cointainer.prependChild(floatDiv3); 
    Which will change the HTML to:

    Code:
    <div id="container">
       <div class="floatLeft"></div>
       <div class="floatLeft"></div>
       <div class="floatLeft"></div>
       <br class="clear" />
    </div>
    Last edited by NeoDreamer; January 8th, 2009 at 12:27 AM.

  2. #2
    If there's no clean solution, I'll just use this hack I just thought of:

    Code:
    <div id="containerOuter">
       <div id="container">
       </div>
       <br class="clear" />
    </div>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012