Removing all Matching Classes in jQuery

Posted by Seth Duncan on Stack Overflow See other posts from Stack Overflow or by Seth Duncan
Published on 2010-05-06T18:28:49Z Indexed on 2010/05/06 18:38 UTC
Read the original article Hit count: 303

Filed under:

Hi I have an li element that will have something along the lines of this for a declaration

<li class="module ui-helper-fix">

And I can dynamically change the color of the module by adding on classes (That are provided dynamically through DB calls) the end result being

<li class="module ui-helper-fix module-green">

or

<li class="module ui-helper-fix module-default"> 

Well I am fine with changing the color by adding on a new module-WHATEVER class but what I would like to do is remove any class that matches module-XXXX so it starts with a clean slate and then add on the class module-crimson.

So how do I remove all classes that match module-xxx first ? Keeping in mind I don't want to remove the base module class.

Thanks.

-Seth

© Stack Overflow or respective owner

Related posts about jQuery