Skip to content

Instantly share code, notes, and snippets.

@Kasahs
Last active January 28, 2016 08:40
Show Gist options
  • Save Kasahs/c6a21716287c70644562 to your computer and use it in GitHub Desktop.
Save Kasahs/c6a21716287c70644562 to your computer and use it in GitHub Desktop.
remove node from DOM by calling element.remove()
Element.prototype.remove = function() {
this.parentElement.removeChild(this);
};
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
for (var i = 0, len = this.length; i < len; 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