js append element to html code example
Example 1: 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);
Example 2: JavaScript append HTML
let app = document.querySelector('#app');
app.append('append() Text Demo');
console.log(app.textContent);