Remove all classes except one
Well, I know that with some jQuery actions, we can add a lot of classes to a particular div: <div class="cleanstate"></div> Let's say that with some clicks and other things, the div gets a lot of classes <div class="cleanstate bgred paddingleft allcaptions ..."></div> So, how I can remove all the classes except one? The only idea I have come up is with this: $('#container div.cleanstate').removeClass().addClass('cleanstate'); While removeClass() kills all the classes, the div get screwed up, but adding just after that addClass('cleanstate') it goes back to normal. The other solution is to put