Remove All childNodes


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. var holder = document.getElementById("whateverDiv");//the holder div
  2.  
  3. while(holder.hasChildNodes()){
  4. holder.removeChild(holder.lastChild);
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.