Javascript examples for DOM:Element removeChild
Element removeChild Method - Find out if a list has any child nodes. If so, remove its first child node (index 0):
<!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 w w. ja v a 2 s . c om*/ var list = document.getElementById("myList"); if (list.hasChildNodes()) { list.removeChild(list.childNodes[0]); } } </script> </body> </html>