mpgn mpgn - 7 months ago 39
HTML Question

Set link of my navbar active with bootstap

I try to set active the element of my navbar when i click on the button.

My navbar is like that :


But when i click on the "a" for exemple, the "G" remains active.

My code is like that :

<div class="navbar span8" id="navbar">
<div class="navbar-inner">
<ul class="nav">
<li><a href="#a">A</a></li>
<li><a href="#b">B</a></li>
<li><a href="#c">C</a></li>
<li><a href="#d">D</a></li>
<li><a href="#e">E</a></li>
<li><a href="#f">F</a></li>

To set a class active the code is :

<li class="active"><a href="#f">F</a></li>

How can i do that with jQuery ?


You can set it active like this..

$('.nav li').click(function(){
    $('.nav li').removeClass('active');