Skip to content

Instantly share code, notes, and snippets.

@fervic
Created April 18, 2015 21:12
Show Gist options
  • Save fervic/f7130750507e442f36b9 to your computer and use it in GitHub Desktop.
Save fervic/f7130750507e442f36b9 to your computer and use it in GitHub Desktop.
Romove class by regex jQuery extension
//------------------------------------------------------------------------------
// Remove class by Regex
// Array.filter for IE<9: https://gist.github.com/eliperelman/1031656
[].filter||(Array.prototype.filter=function(a,b,c,d,e){c=this;d=[];for(e in c)~~e+''==e&&e>=0&&a.call(b,c[e],+e,c)&&d.push(c[e]);return d});
// http://stackoverflow.com/a/18621161
$.fn.removeClassRegex = function(regex) {
return $(this).removeClass(function(index, classes) {
return classes.split(/\s+/).filter(function(c) {
return regex.test(c);
}).join(' ');
});
};
//------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment