2
Good guys, I need to create a way to recognize which menu I am clicking on, I have my index where I call my menus with a include, so I need to put a green bar at the bottom of the menu that is clicked.
How to do this ?
<ul class="mainnav">
<li class="active"><a href="principal.php"><i class="icon-dashboard"></i><span>Início</span> </a> </li>
<li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-sort"></i><span>Cadastro</span> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="listaUsuario.php">Usuários</a></li>
<li><a href="listaPublicacao.php">Publicação</a></li>
<li><a href="#">Clientes</a></li>
<li><a href="#">Paginas Internas</a></li>
</ul>
</li>
<li><a href="cadastroMenu.php"><i class="icon-th-list"></i><span>Menu</span> </a></li>
<li><a href="#"><i class="icon-picture"></i><span>Banner</span> </a> </li>
<li><a href="#"><i class="icon-book"></i><span>Contatos</span> </a> </li>
</ul>
I just need to add active
in the li class that is in selection. An example is
Be able to do, however it activates Active in the class, but it is a few seconds returning only to read marked main, the goal to start the index as Active is for it to appear checked as soon as the site is started, someone has some better idea that will solve this problem.
$(function () {
$('.mainnav li').on('click', function(){
$(this).addClass('dropdown active');
$(this).siblings().removeClass('active');
});
});
Is that a website? , are you using any CMS or framework to develop?
– Erlon Charles
use the CSS selector
li:hover a
, has an answer that may help: http://answall.com/a/42669– Pedro Sanção
@Erloncharles yes is a framework
– Renan Rodrigues
@Sanction is not this way, I want dynamic.
– Renan Rodrigues
Let me see if I understand, you want when you are on a page the link on the link on this page already come marked is this?
– Erlon Charles
@Erloncharles get the Caio showed how to do the right way, thanks for the collaboration.
– Renan Rodrigues