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.

The code im using is the one below.

Thanks!

<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>

$("#nav li a").click(function(){
    $("#nav li a").removeClass("current").addClass("hidden");
    $(this).addClass("current");
});

Reply via email to