Replace class depending on event
<p>If have a set of collapsible elements, in which I need to replace classes <em>left</em> and <em>right</em> depending on event <em>isCollapse</em>:</p>

<pre><code>&lt;div class="collapsible-set"&gt;
  &lt;div class="collapsible"&gt;
      &lt;h3&gt;
        &lt;a class="left"&gt;
           &lt;span class="left"&gt;&lt;/span&gt;
        &lt;/a&gt;
      &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="collapsible"&gt;
      &lt;h3&gt;
        &lt;a class="right"&gt;
           &lt;span class="right"&gt;&lt;/span&gt;
        &lt;/a&gt;
      &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I need to toggle the classes. Is there an eaiser way to do this than what I came up with?</p>

<pre><code>if (collapse) {
  $('.left').addClass('topLeft').removeClass('left');
  $('.right').addClass('topRight').removeClass('right');
  } else if (!collapse) {
    $('.topLeft').addClass('left').removeClass('topLeft');
    $('.topRight').addClass('right').removeClass('topRight');
    }
</code></pre>

<p>There must be an eaiser way to do this without writing so much code...</p>
