[jQuery] Help with Add/Removing Classes
<div>Guys, I have a problem with my menu. I am trying to add and remove classes when clicking on the main menu links. For instance when on load, the 'Home' is the current tab clicked, but when I click on 'Contact Me' I would like the class current to be removed from 'Home' and added to 'Contact Me' instead.</div>
<div> </div>
<div>The code im using is the one below.</div>
<div> </div>
<div>Thanks!</div>
<div> </div>
<div><ul id="nav">
<li><a class="top current" href="#">Home</a></li>
<li><a class="top" href="#">Colours</a>
<ul>
<li><a href="#">Red</a></li>
<li><a href="#">Green</a></li>
<li><a href="#">Black</a></li>
</ul>
</li>
<li><a class="top" href="#">Contact Me</a></li>
</ul>
</div>
<div>$("#nav li a").click(function(){
$("#nav li a").removeClass("current").addClass("hidden");
$(this).addClass("current");
});</div>