Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes all elements from a NodeList. This NodeList is generally a document element query result.
/**
* Removes all elements from a NodeList.
* This NodeList is generally a document element query result.
* @author TheRolf
*/
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
for(var i = this.length - 1; i >= 0; i--) {
if(this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment