title: jQuery: adding class to link if its clicked
body: <p>I call jquery function onclick  at links. For example:</p>
  
  <pre><code>&lt;a class="active" href="#" onClick="Animate2id('#box1');" &gt;Content 1&lt;/a&gt;
  &lt;a href="#" onClick="Animate2id('#box2');" &gt;Content 2&lt;/a&gt;
  &lt;a href="#" onClick="Animate2id('#box3');" &gt;Content 3&lt;/a&gt;
  </code></pre>
  
  <p>As you can see, first link has by default class 'active'. I want to remove the class from first link and add to the link which is clicked.
  For that purpose, I'm trying to add following line inside the Animate2id function:</p>
  
  <pre><code>$('.active').removeClass('active');
  $(this).addClass('active');
  </code></pre>
  
  <p>It just removes the class from the link.
  But this does not add the class to any of the link. How I can fix that?</p>
  
  <p><strong>Edit:</strong>
  Here is complete jQuery function:</p>
  
  <pre><code>function Animate2id(id){ 
      var animSpeed=2000; 
      var $container=$("#container"); 
      if(ease){ 
          var easeType=ease;
      } else {
          var easeType="easeOutQuart"; 
      }
  
      $container.stop().animate({"left": -($(id).position().left)}, animSpeed, easeType);
  }
  </code></pre>