addAndRemoveClassJquery 1

addAndRemoveClassJquery

$('#menu li a').on('click', function(){
    $('#menu li a.current').removeClass('current');
    $(this).addClass('current');
});

Here is what the above code is Doing:
1. When the page loads, the first link in the menu is given the class “current”.
2. When a link is clicked, the “current” class is removed from the current link and added to the clicked link.

Similar Posts