You might know appendChild method which allows you to add an element to the end of another. Like this:

someParentObject = document.getElementById("someid");
someChildObject = document.createElement("div");
someChildObject.innerHTML = 'Content';
// append the someChildObject to the end of someParentObject

But what to do if you want to add the child object to the very beginning of parent object? I noticed many people are searching for prependChild method. Strange, but… there is no such method.:) Yet there is another trick:


I hope it will help anybody.;-)

UPD. Thanks for people, who noticed my mistake. Of course I was thinking about insertBefore, not appendChild.