Answers for "how to add an element to a li item from js to html"

0

append li to ul javascript

function function1() {
  var ul = document.getElementById("list");
  var li = document.createElement("li");
  li.appendChild(document.createTextNode("Four"));
  ul.appendChild(li);
}
Posted by: Guest on September-30-2020
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);
Posted by: Guest on December-30-2020

Code answers related to "how to add an element to a li item from js to html"

Code answers related to "Javascript"

Browse Popular Code Answers by Language