I am trying to get the navigation bar focused white when you click on any link.
Here is the code :
$('.navbar li').click(function (e) {
$('.navbar li.active').removeClass('active');
var $this = $(this);
if (!$this.hasClass('active')) {
$this.addClass('active');
}
e.preventDefault();
});
As you see that this works fine. Which ever links I click it gets actibve(white) and the others get dark.
But as you can see that e.preventDefault();
prevents the link action. When I get rid of that line then it does full refresh the whole page and then I again lose the active link. Somehow I kind of need to or use ajax to load the page content(Which I do not prefer to do) or Is there any other way?