dom append to document code example
Example 1: create and append element in javascript
//create and append element
var node = document.createElement("LI"); // Create a <li> node
var textnode = document.createTextNode("Water"); // Create a text node
node.appendChild(textnode); // Append the text to <li>
document.getElementById("myList").appendChild(node);
Example 2: how to appendChild in the begin of the div javascript
var element = document.getElementById("div1");
element.insertBefore(para, element.firstChild);