JavaScript DHTML/Node Operation/removeChild
"removeChild()" Example
<source lang="html4strict">
<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>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
<input type="button" value="Add list item" onClick="function1();"> <input type="button" value="Remove added items" onClick="function2();"> </body> </html>
</source>