Skip to content

Instantly share code, notes, and snippets.

@kotarok
Created June 24, 2009 08:21
Show Gist options
  • Save kotarok/135090 to your computer and use it in GitHub Desktop.
Save kotarok/135090 to your computer and use it in GitHub Desktop.
replace class by RegExp
(function($){
$.fn.replaceClass = function(RE,STR) {
return this.each(function(){
var classes = $(this).attr('class').split(/\s/);
$.each(classes,function(i){classes[i] = this.replace(RE,STR)})
$(this).attr('class',classes.join(' '));
})
};
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment