Click to See Complete Forum and Search --> : Variations of appendChild??


jovialjonny
08-07-2003, 09:00 AM
Hi,
I am adding some elements to my webpage with the .appendChild method. The problem I am having is every time I call appendChild I want the newest element appended before the last one.

Eg.
Step 1:
<span id="container>
<!-- new elements are added in here -->
</span>

(After a new element is appended...)
Step 2:
<span id="container>
<div class="myButton"></div>
<!-- next element will go here, but I want it before not after!! -->
</span>

Append child automatically appends after the last element, I was wondering does anyone know is there a way around this or is there a similar method such as 'appendFirst' or something that I can use??

gil davis
08-07-2003, 04:08 PM
Look intoinsertBefore()

jovialjonny
08-08-2003, 09:39 AM
Exactly what I needed thanks! :)