title: jQuery - how do I add a class on li element when I click?
body: <p>I've found a lot of similar questions but unfortunately none really help with my problem...</p>
  
  <p>I have a navigation list</p>
  
  <pre><code>&lt;div class="nav-container"&gt;
       &lt;ul&gt;
            &lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to give a class to the anchor tag (not the 'li') when I click on it. So far I have:</p>
  
  <pre><code>$(".nav-container li a").click(function(){
      $('.nav-container li a').removeClass('nav-active');
      $(this).addClass('nav-active');
  })
  </code></pre>
  
  <p>It seems to add the class for a split second and then disappear. </p>
  
  <p>I've managed to get the class to apply by using 'return false;' at the end but it stops the actual links from working all together.</p>
  
  <p>I'm guessing one is cancelling the other out and it just needs some way to stop it... not quite sure how you do that (sorry - new to jQuery)</p>
  
  <p>Thanks in advance to anyone who can sort my issue out :)</p>