Last active
October 28, 2015 20:43
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOMTokenList.prototype.removeByPartial = function (className) { | |
for (var i = 0; i< this.length; i++) { | |
if (this[i].indexOf(className) !== -1) { | |
this.remove(this[i]); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Latest extends the classList prototype. This way it can work on more than just HTMLElement