Skip to content

Remove all child elements of a DOM node in JavaScript

Learn how to remove all child elements of a HTML DOM node in JavaScript.

var list = document.getElementById("myList");
   while (list.hasChildNodes()) {
      list.removeChild(list.firstChild);
   }
}
See also  Number of Segments in a String - Leetcode Challenge - Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.