Posted By

1man on 03/13/07


DOM remove childnodes

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Remove All childNodes

 / Published in: JavaScript

This while loop will remove all childNodes from a selected element.

  1. var holder = document.getElementById("whateverDiv");//the holder div
  3. while(holder.hasChildNodes()){
  4. holder.removeChild(holder.lastChild);
  5. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: rohan1987 on October 28, 2010

Very nice and handy snippet. Thanks "1man".

You need to login to post a comment.