<head><script> $(document).ready(function() { $('div.nb ul li a').click(function() { $('div.nb ul li').each(function(index) { $(this).removeClass('active'); }); //remove active class from each li element $(this).parent().addClass('active'); //add active class to li element that is parent of clicked a element }); }); </script></head>