Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add li to ul javascript

function function1() {
  var ul = document.getElementById("list");
  var li = document.createElement("li");
  li.appendChild(document.createTextNode("Four"));
  li.setAttribute("id", "element4"); // added line
  ul.appendChild(li);
  alert(li.id);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #li #ul #javascript
ADD COMMENT
Topic
Name
2+4 =