Add and remove class on click
<p>I have a tab menu, and i want onlick be be added a <code>class="selected"</code> - and on click on one of the other tabs, the class should be removed from the current link, and then be added to the link i've clicked on...</p>

<p>I've tried this but didnt work</p>

<pre><code>$('.tab-links a').click(function(){
   $(this).toggleClass('selected');
});
</code></pre>

<p>And the HTML: </p>

<pre><code>&lt;section class="tabs"&gt;
&lt;nav class="tab-links"&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;a href="/min+side/Mine+favoritter" class="ajax-tab-fav myoptionstab"&gt;MIne favoritter&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href="/min+side/Mine+jobagenter" class="ajax-tab-jobagents myoptionstab"&gt;Jobagenter&lt;/a&gt;
    &lt;/li&gt;
    &lt;li class="last"&gt;
      &lt;a href="/min+side/Rediger+bruger" class="ajax-tab-edituser myoptionstab"&gt;Indstillinger&lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/nav&gt;
&lt;div class="clear"&gt;
  &lt;!----&gt;
&lt;/div&gt;
</code></pre>

<p></p>
