title: Remove all classes except one
body: <p>Well, I know that with some jQuery actions, we can add a lot of classes to a particular div:</p>
  
  <pre><code>&lt;div class="cleanstate"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Let's say that with some clicks and other things, the div gets a lot of classes</p>
  
  <pre><code>&lt;div class="cleanstate bgred paddingleft allcaptions ..."&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So, how I can remove all the classes except one? The only idea I have come up is with this:</p>
  
  <pre><code>$('#container div.cleanstate').removeClass().addClass('cleanstate');
  </code></pre>
  
  <p>While <code>removeClass()</code> kills all the classes, the div get screwed up, but adding just after that <code>addClass('cleanstate')</code> it goes back to normal. The other solution is to put an ID attribute with the base CSS properties so they don't get deleted, what also improves performance, but i just want to know another solution to get rid of all except ".cleanstate"</p>
  
  <p>I'm asking this because, in the real script, the div suffers various changes of classes.</p>