Skip to content

Instantly share code, notes, and snippets.

@jakubp
jakubp / gist:2881585
Created June 6, 2012 12:31
jQuery plugin to remove classes with given prefix
// 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"
// NOTE: discussion of implementation techniques for this, including why simple RegExp with word boundaries isn't correct:
// http://stackoverflow.com/questions/57812/jquery-remove-all-classes-that-begin-with-a-certain-string#comment14232343_58533