Skip to content

Instantly share code, notes, and snippets.

@paceaux
Last active October 28, 2015 20:43
Show Gist options
  • Select an option

  • Save paceaux/b5aa08bc91fe3abd14ab to your computer and use it in GitHub Desktop.

Select an option

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

paceaux commented Oct 28, 2015

Copy link
Copy Markdown
Author

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