title: Using JQuery removeClass() to remove all classes but one
body: <p>Okay, I've got an interesting one (well, interesting to me, anyway   :)   ).</p>
  
  <p>I've got a situation where I have a div with a static class value, but it also can have a single, "secondary class" assigned that is dynamic.  When the user makes a selection, any existing secondary class needs to be removed and the new class added.</p>
  
  <p>Ignoring using an id value (standards for the project use the class . . . can't be changed), is there an elegant way to simply ignore the first class and remove whatever other class is there, before adding the new one?</p>
  
  <p>Example Starting HTML:</p>
  
  <pre><code>&lt;div class="staticClass dynaClass1" /&gt;
  </code></pre>
  
  <p>Example JS:</p>
  
  <pre><code>function updateClass(newSecondaryClass) {
      $(".staticClass") . . . **** remove any class besides "staticClass" ****
      $(".staticClass").addClass(newSecondaryClass);
  }
  </code></pre>
  
  <p>If the function is called using <code>updateClass("dynaClass2");</code>, the resulting HTML should be:</p>
  
  <pre><code>&lt;div class="staticClass dynaClass2" /&gt;
  </code></pre>
  
  <p>I can think of ways of doing it involving just removing all classes using <code>removeClass();</code> and adding "staticClass" back in when adding the new class, or using <code>attr("class", "staticClass " + newSecondaryClass);</code>, but I'm wondering if there isn't a way to handle it without having to touch the static class at all?</p>
  
  <p>In the end, I guess this is an academic question, more than anything . . . just seems like it's something that should be doable, but I don't know how to do it.  :D</p>