'removeChild()' Example : removeChild : Node Operation JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Node Operation » removeChild »

 

'removeChild()' Example



    
<html>
<body>
<script language="JavaScript">
function function1() {
    var m = "New Element";
    var n = document.createElement("li");
    n.appendChild(document.createTextNode(m));
    document.getElementById("myList").appendChild(n)

function function2() {
    myList.removeChild(myList.lastChild);
}
</script>
<ul id="myList">
   <li>1</li>
   <li>2</li>
   <li>3</li>
   <li>4</li>
   <li>5</li>
   <li>6</li>
   <li>7</li>
   <li>8</li>
   <li>9</li>
</ul>
<input type="button" value="Add list item" onClick="function1();">
<input type="button" value="Remove added items" onClick="function2();">
</body>
</html>

    
      
      



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Node Operation
» removeChild