add element with text javascript code example
Example 1: JavaScript append text to div
var div = document.getElementById('myElementID');
div.innerHTML += "Here is some more data appended";
Example 2: javascript append to paragraph
// In the JS script
var parElement = document.getElementById("myPar");
var textToAdd = document.createTextNode("Text to be added");
parElement.appendChild(textToAdd);
//In the HTML file
<p id="myPar"></p>