1
I’m trying to put an active class in the navbar, I’m using bootstrap, what happens is that when I click on the li, the background color appears but soon it disappears. Follow the code I’m using the css:
.navbar-nav > .active {
background-color: green !important;
}
the jquery
$('ul.navbar-nav > li ').click(function() {
$('ul.navbar-nav > li').removeClass('active');
$(this).addClass('active');
});
the html
<div class="collapse navbar-collapse" id="navcollapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-
toggle="dropdown" aria-haspopup="true" aria-expanded="false"
href="#">Serviços</a>
<ul class="dropdown-menu">
<li><a href="dados.html">Dados</a></li>
<li><a href="ficha.html">ficha</a></li>
/ul>
</li>
<li><a href="noticias.html">Notícias</a></li>
<li><a href="contato.html">Contato</a></li>
</ul>
Enter the HTML code as well
– JuniorNunes