1

I have been using appendChild to attach items to a div.

The default behaviour is to attach items to the bottom of the container div, but I want items to be appended to the top.

How can I do this?

3 Answers3

1

try using insert before

parentDiv.insertBefore(newDiv, parentDiv.firstChild);
Shlomi Komemi
  • 5,445
  • 3
  • 28
  • 41
  • Thanks a lot guys. but I've already figured it out. instead of putting AppendChild, I changed it to PrependChild. and it works good. :) – jade calingin Feb 12 '12 at 08:20
1

I've already figured it out. instead of putting AppendChild, I changed it to PrependChild. and it works good.

0

javascript: You have to insert in not append it :).

c# (asp.net): div.innerHTML = custom_html + div.innerHTML

link: Can I dynamically add HTML within a div tag from C# on load event?

Community
  • 1
  • 1
elrado
  • 4,960
  • 1
  • 17
  • 15
  • Thanks a lot guys. but I've already figured it out. instead of putting AppendChild, I changed it to PrependChild. and it works good. – jade calingin Feb 12 '12 at 08:07