Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
Created August 13, 2011 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodneyrehm/1143785 to your computer and use it in GitHub Desktop.
Save rodneyrehm/1143785 to your computer and use it in GitHub Desktop.
$.fn.removeClass(RegExp);
/*
* allow to pass a RegExp to remove class
* Example:
* $('.foobar).removeClass(/some-pattern-[a-z]+/g);
*/
var $removeClass = $.fn.removeClass;
$.fn.removeClass = function(className) {
if (className.constructor.name === "RegExp") {
return $removeClass.call(this, function() {
return (this.className.match(className) || []).join(' ');
});
}
return $removeClass.call(this, className);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment