I have a div and i want to append another div inside it. but, by using appendChild() it always insert DOM element in end of container element.but i want to inse
appendChild()
You can use prepend() on the parent element to add a child first.
http://api.jquery.com/prepend/
I don't have time to test it, but i think that will work.
var newDiv= document.createElement('div'); newDiv.innerHTML = ""; var item = document.getElementById('containerDivId'); item.prepend(newDiv);