Created
June 24, 2009 08:20
-
-
Save kotarok/135089 to your computer and use it in GitHub Desktop.
be able to remove class by RegExp
This file contains 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
(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