JS -appendChild - Jquery append

by Alejandro M

HTML

<div id="myList"></div>
<button onclick="myFunction()">Try it</button>

JavaScript

function myFunction() {
  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); // Append <li> to <ul> with id="myList"
}