Skip to content

Instantly share code, notes, and snippets.

@damianociarla
Last active October 28, 2015 11:22
Show Gist options
  • Save damianociarla/a9361a53662ba9ffe3c2 to your computer and use it in GitHub Desktop.
Save damianociarla/a9361a53662ba9ffe3c2 to your computer and use it in GitHub Desktop.
Remove all suffix-classes from selected elements
jQuery.fn.extend({
removeSuffixClass: function(prefix) {
return this.removeClass(function (index, css) {
var pattern = '\\b'+prefix+'\\S+';
var re = new RegExp(pattern, 'g');
return (css.match(re) || []).join(' ');
});
}
});
// Example
// $('i.fa').removeSuffixClass('fa-');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment