Last active
October 28, 2015 11:22
-
-
Save damianociarla/a9361a53662ba9ffe3c2 to your computer and use it in GitHub Desktop.
Remove all suffix-classes from selected elements
This file contains hidden or 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
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