title: Jquery adding and removing class dynamically
body: <p>I am trying to add the class"selected"  when a link is clicked and when the user click on the next link , I want to remove the previously "selected" class and add "selected" to the link clicked.. </p>
  
  <p>-Thanks in advance</p>
  
  <pre><code>$(document).ready(function() {
  $('.news a').click(function(){
    $(this).addClass("selected");
  });
  });
  
  &lt;div class="news-w"&gt;
              &lt;div class="news" id="getnews-1"&gt;
              &lt;a href="#" &gt;topic&lt;/a&gt;
              &lt;/div&gt;
              &lt;div class="news" id="getnews-2"&gt;
              &lt;a href="#"&gt;topic&lt;/a&gt;
              &lt;/div&gt;      
              &lt;div class="news" id="getnews-3"&gt;
              &lt;a href="#" &gt;topic&lt;/a&gt;
              &lt;/div&gt;      
              &lt;div class="news" id="getnews-4"&gt;
              &lt;a href="#"&gt;topic&lt;/a&gt;
              &lt;/div&gt;      
              &lt;div class="news" id="getnews-5"&gt;
              &lt;a href="#"&gt;topic&lt;/a&gt;
              &lt;/div&gt;                      
      &lt;/div&gt;
  </code></pre>