Skip to content

Instantly share code, notes, and snippets.

@paceaux
Last active October 28, 2015 20:43
Show Gist options
  • Save paceaux/b5aa08bc91fe3abd14ab to your computer and use it in GitHub Desktop.
Save paceaux/b5aa08bc91fe3abd14ab to your computer and use it in GitHub Desktop.
Use this if you want to remove a class name from an element, but you don't know the full class name (ie, you only have a partial class name)
DOMTokenList.prototype.removeByPartial = function (className) {
for (var i = 0; i< this.length; i++) {
if (this[i].indexOf(className) !== -1) {
this.remove(this[i]);
}
}
};
@paceaux
Copy link
Author

paceaux commented Oct 28, 2015

Latest extends the classList prototype. This way it can work on more than just HTMLElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment