Jquery change CSS class on clicking
<p>I am working on a project i am having some anchors like tab, each have some CSS class, the selected tab have separate css class. I am clicking on tab and i want to change its CSS class  to selected css class i have done this functionality but i am having some problems with it is that previously selected  tab also having same class, how can i change the previous selected tab to unselected class,Below is my code</p>

<pre><code>$(".btn").each(function ()
{
    $(this).click(function () {                              
        $(this).removeClass("course-btn-tab").addClass("course-btn-tab-selected");        
    });
});

&lt;div class="course-Search-tabs"&gt;
    &lt;a href="#" class="course-btn-tab-selected btn" id="a"&gt;A&lt;/a&gt;
    &lt;a href="#" class="course-btn-tab btn" id="b"&gt;B&lt;/a&gt;
    &lt;a href="#" class="course-btn-tab btn" id="c"&gt;C&lt;/a&gt;
    &lt;a href="#" class="course-btn-tab" id="d"&gt;D&lt;/a&gt;
&lt;/div&gt;</code></pre>
