html javascript create new element code example
Example 1: js create element
var newDiv = document.createElement("div");
document.body.appendChild(newDiv);
Example 2: 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);