To create a new element with Javascript, you use the createElement method of the document object.
var newDiv = document.createElement("div");
To add new text using Javascript, you can use the createTextNode method of the document object.
var text = document.createTextNode("Text goes here");
Ruslan Ismagilov
source share