Last active
November 10, 2017 01:11
-
-
Save andreasvirkus/bfaedc839de0d46ffe4c to your computer and use it in GitHub Desktop.
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
/** | |
* author: andreas johan virkus | |
* snippet url: https://gist.github.com/andreasvirkus/bfaedc839de0d46ffe4c | |
* | |
* Remove classes that have given prefix | |
* Example: You have an element with classes "apple juiceSmall juiceBig banana" | |
* You run: | |
* $elem.removeClassPrefix('juice'); | |
* The resulting classes are "apple banana" | |
*/ | |
$.fn.removeClassPrefix = function (prefix) { | |
this.each( function ( i, it ) { | |
var classes = it.className.split(" ").map(function (item) { | |
return item.indexOf(prefix) === 0 ? "" : item; | |
}); | |
it.className = classes.join(" "); | |
}); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment