how to add text in js code example
Example 1: javascript append to paragraph
var parElement = document.getElementById("myPar");
var textToAdd = document.createTextNode("Text to be added");
parElement.appendChild(textToAdd);
<p id="myPar"></p>
Example 2: js add more text to element
document.getElementById("p").textContent += " This is the text from javascript.";
<p id ="p">This is the text from HTML.</p>
Example 3: how add text to element in javascript
var h = document.createElement("H1")
var t = document.createTextNode("Hello World");
h.appendChild(t);
Example 4: how add text to element in javascript
var p = document.getElementById("p")
p.innerText = p.innerText+" And this is addon."