Skip to content

Instantly share code, notes, and snippets.

@kotarok
Created June 24, 2009 08:20
Show Gist options
  • Save kotarok/135089 to your computer and use it in GitHub Desktop.
Save kotarok/135089 to your computer and use it in GitHub Desktop.
be able to remove class by RegExp
(function($){
$.fn._removeClass = $.fn.removeClass
$.fn.removeClass = function(arg) {
return this.each(function(){
if(typeof(arg.test) == 'function'){
var classes = $(this).attr('class').split(/\s/);
$.each(classes,function(i){if(arg.test(this)){classes.splice(i,1)}});
$(this).attr('class',classes.join(' '));
}else{
$(this)._removeClass(arg);
}
})
};
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment