javascript append html string 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: jquery append
$("p").append(" <b>Appended text</b>.");
Example 3: 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 4: jquery append element to body
$( ".inner" ).append( "<p>Test</p>" );
Example 5: how to appendChild in the begin of the div javascript
var element = document.getElementById("div1");
element.insertBefore(para, element.firstChild);
Example 6: how to append in javascript
var list=[1, 2, 3, 4, 5];
list.push(6);