I would move the class to <li> , for example:
$('.nav li').click(function() { $(this).addClass("active").siblings().removeClass("active"); });
If you just change the style to fit, for example:
li.active a { }
... then it is much easier to use the click handler for the <li> elements, since this is the set you are dealing with. There is also a more efficient .delegate() method:
$('.nav').delegate('li', 'click', function() { $(this).addClass("active").siblings().removeClass("active"); });
source share