1
Guys, I’m coming back here again with my question.
I got a code that made the :hover
was selected on the current page, but it’s not working, would anyone tell me why?
Follow the codes:
<script type="text/javascript">
$(document).ready(function() {
$('li').click(function() {
$('li.active').removeClass("active"); //aqui removemos a class do item anteriormente clicado para que possamos adicionar ao item clicado
$(this).addClass("active"); //aqui adicionamos a class ao item clicado
});
});
</script>
<div id="menufundo">
<nav id="menuhorizontal">
<ul>
<li><a href="index.html" class="active">Home</a></li>
<li><a href="contato.html" class="active">Contato</a></li>
<li><a href="endereco.html" class="active">Endereço</a></li>
<li><a href="programacao.html" class="active">Programação</a></li>
</ul>
</nav>
</div>
and the css:
#menuhorizontal ul li a {
padding: 2px 10px;
margin-top: 15px;
display: inline-block;
/*visual do link*/
color: #ffffff;
text-decoration: none;
}
#menuhorizontal ul li a:hover, ul li.active a {
background-color: #FFFFFF;
color: #0700fc;
border-bottom: 3px solid #0700fc;
border-radius: 10px;
color: #fff !important;
}
Can explain better what it means "Hover stay selected on the current page" ?
– Pablo Almeida
@Pablo, for example, if I am on the HOME page, stay a highlighted Hover in the HOME option in the menu, so the user knows where it is, understood?
– Júlio César
What do you mean by "Hover"?
– Pablo Almeida
It doesn’t work because when you click on the item your page will refresh and the class you added via jquery will get lost. I answered your other question with a solution all made via css. Take a look there.
– user41722
@Eduardokawanaka, thank you so much! I’m a beginner in the area, and I’m still getting a lot of headbutts
– Júlio César
It’s all in, buddy.
– user41722