document.add element javascript code example
Example 1: insert element to dom
var node = document.createElement("LI");
var textnode = document.createTextNode("Water");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
Example 2: javascript document.createElement add function
var newTH = document.createElement('th');
newTH.innerHTML = 'Hello, World!';
newTH.onclick = function () {
this.parentElement.removeChild(this);
};
var table = document.getElementById('content');
table.appendChild(newTH);