document appendchild to beginning code example
Example: how to appendChild in the begin of the div javascript
var element = document.getElementById("div1");
element.insertBefore(para, element.firstChild);
var element = document.getElementById("div1");
element.insertBefore(para, element.firstChild);