Javascript examples for DOM:Element removeChild
Element removeChild Method - Remove all child nodes of a list:
<!DOCTYPE html> <html> <body> <ul id="myList"><li>Coffee</li><li>Tea</li><li>Milk</li></ul> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w ww .j a va 2s .c o m*/ var list = document.getElementById("myList"); while (list.hasChildNodes()) { list.removeChild(list.firstChild); } } </script> </body> </html>