How would I go about removing all of the child elements of a DOM node in JavaScript?
Say I have the following (ugly) HTML:
&
Here is what I usually do :
HTMLElement.prototype.empty = function() { while (this.firstChild) { this.removeChild(this.firstChild); } }
And voila, later on you can empty any dom element with :
anyDom.empty()