Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Created October 14, 2011 09:43
Show Gist options
  • Save craigmdennis/1286698 to your computer and use it in GitHub Desktop.
Save craigmdennis/1286698 to your computer and use it in GitHub Desktop.
Remove a class on a wildcard basis
function removeWildcardClass(string, element) {
$(element).each(function () {
var aryClasses = $(this).attr('class').split(' ');
for (var i = 0; i < aryClasses.length; i++) {
if (aryClasses[i].indexOf(string) != -1) {
$(this).removeClass(aryClasses[i]);
}
}
});
}
@craigmdennis
Copy link
Author

Would like to turn into plugin to mimic existing .removeClass('class-name'); behaviour

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