Forum Moderators: open

Message Too Old, No Replies

appendChild in reverse order

         

user9

9:55 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



Hi everyone

I have the following code


function insrt(lastData)
{
var para=document.createElement('P');

var lastData=document.createTextNode(lastData);

out=document.getElementById('out'); //out is a div

para.appendChild(lastData);
out.appendChild(para);
}

The function works well, but instead of simply appending the contents of lastData, I would like it to prepend.

As far as I understand, the method I'm looking for is insertBefore as described here [howtocreate.co.uk...] However, I don't understand how I should reference my output in order to prepend the data.

Thanks in advance

user9

5:58 am on Jan 12, 2005 (gmt 0)

10+ Year Member


Problem solved thanks to 7stud over at http://www.sitepoint.com

http://www.sitepoint.com/forums/showthread.php?t=224008