1
Could someone help me understand why by clicking on menu options, sometimes the container loses the Hover and closes the container?
Below follows my code:
<style>
ul.nav-menu__consultora,
ul.nav-menu__consultora ul{
padding: 0;
margin: 0;
position: relative;
}
ul.nav-menu__consultora ul li{
padding: 5px;
}
.nav-menu__consultora{
cursor: pointer;
}
.menu__consultor,
.opcao--queiro-consultor-type,
.opcao--soy-consultor-type{
display: none;
}
.option-consultor:hover .menu__consultor,
.open{
display: block;
}
.nav-menu__consultora li {
list-style: none;
}
</style>
<nav class="menu-header__consultora">
<ul class="nav-menu__consultora">
<li class="option-consultor">Consultor(a)
<ul class="menu__consultor">
<li class="opcao--queiro-consultor opcao--consultor">Quiero ser Consultor(a)
<ul class="opcao--queiro-consultor-type opcao-type">
<li>Digital</li>
<li>Presencial</li>
</ul>
</li>
<li class="opcao--soy-consultor opcao--consultor"> Soy Consultor(a)
<ul class="opcao--soy-consultor-type opcao-type">
<li>Digital</li>
<li>Presencial</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<script>
var opcoesConsultor = document.querySelectorAll('.opcao--consultor');
var opcoesType = document.querySelectorAll('.opcao-type');
opcoesConsultor.forEach(function(opcao, i){
opcao.addEventListener('click', function(e){
opcoesType[i].classList.toggle('open');
})
})
</script>
Thanks a lot dvd, it worked out man. Thanks a lot.
– Filype Ferreira