On the Bootstrap website the subnav matches up with the sections and changes background color as you or scroll to the section. I wanted to create my own menu without all the
This is getting pretty old and clustered with answers, but I took the top answer and made it better. The top answer only works if there's one on the page. This scopes it to removing active from sibling elements and adding it to the one you clicked.
I also added the class nav-toggle so that it doesn't interfere with things that already have bootstrap js attached.
$('.nav.nav-toggle li').click(function(e) {
var $this = $(this);
$this.siblings().removeClass('active');
if (!$this.hasClass('active')) {
$this.addClass('active');
}
e.preventDefault();
});