title: jQuery replace class
body: <p>I have a large list of <code>&lt;li&gt;</code>'s that are given a width from a 'span3' class. </p>
  
  <pre><code>&lt;ul class="thumbnails"&gt;
      &lt;li class="span3"&gt;
          &lt;div class="thumbnail"&gt;&lt;img src="/images/logos-s/s-001.png" alt="" data-creator="swc"&gt; &lt;span&gt;01&lt;/span&gt;&lt;/div&gt;
      &lt;/li&gt;
      repeat...40x
  &lt;/ul&gt;
  </code></pre>
  
  <p>I have buttons (<code>button#grid-bigger</code> &amp;&amp; <code>button#grid-smaller</code>) that allow the users to increase and decrease the size of the grid on click. Ideally, the user would be able to click three times, and each time it would change the <code>&lt;li&gt;</code> class from span3 to span4 then to span12.</p>
  
  <p>Here's the JavaScript: </p>
  
  <pre><code>$('#grid-bigger').live('click', function (e) {
      $('#blob .thumbnails').find('li').each(function(i, ojb) {
          if ( $(this).hasClass('span2') ) {
              $(this).removeClass('span2').addClass('span3');
          }
  
          if ( $(this).hasClass('span3') ) {
              $(this).removeClass('span3').addClass('span4');
          }
  
          if ( $(this).hasClass('span4') ) {
              $(this).removeClass('span4').addClass('span12');
          }
      });
  });
  </code></pre>
  
  <p>What happens is that instead of allowing separate clicks to the "make bigger" button, it'll only click once and execute two of the statements at the same time.</p>
  
  <p>Any suggestions?</p>