Created
October 28, 2010 03:04
-
-
Save nkohari/650532 to your computer and use it in GitHub Desktop.
Given a regex, will remove all CSS classes that match from an element.
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
jQuery.fn.extend({ | |
removeMatchingClasses: function(pattern) { | |
return this.each(function() { | |
var element = jQuery(this); | |
var classes = element.attr("class").split(/\s+/); | |
jQuery.each(classes, function(idx, class) { | |
if (class.match(pattern)) element.removeClass(class); | |
}); | |
return this; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment