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  Java If-Else - Hackerrank Challenge - Java Solution

Leave a Reply

Your email address will not be published.

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