li node:
var newitem2=document.createElement("li");
var newtext2=document.createTextNode("This is the last list item");
newitem2.style.color="lime";
ulorig is Id on <ul> node,
listorig is Id on a <li> node):
document.getElementById("ulorig").insertBefore(newitem,listorig);
<ul> list:
document.getElementById("ulorig").appendChild(newitem);
listrepl is Id attached to the <li> element
before the one to be replaced):
document.getElementById("ulorig").replaceChild(
newitem,listrepl.nextSibling);
18 of 27 |