Skip to content

Instantly share code, notes, and snippets.

@js2me
Created October 11, 2017 08:31
Show Gist options
  • Save js2me/35ffafd556f2479384664fef84850d5a to your computer and use it in GitHub Desktop.
Save js2me/35ffafd556f2479384664fef84850d5a to your computer and use it in GitHub Desktop.
If you write only on VanillaJS and you dont use jQuery, that gist for you! He include features, which help to you work with DOM elements
Element.prototype.remove = function () {
this.parentElement.removeChild(this);
};
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