Javascript DOM HTML UL remove all child nodes
<!DOCTYPE html> <html> <body> <ul id="myList"><li>CSS</li><li>HTML</li><li>Java</li></ul> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w. j av a 2 s . c om*/ var list = document.getElementById("myList"); while (list.hasChildNodes()) { list.removeChild(list.firstChild); } } </script> </body> </html>