2
I have the following structure:
$(".produtosMenu li span").click(function() {
$(".produtosSubmenu").fadeToggle();
});
.produtosMenu li {
box-sizing: border-box;
-webkit-transition: background-color .5s;
/* For Safari 3.1 to 6.0 */
transition: background-color .5s;
cursor: pointer;
margin-bottom: 5px;
}
.produtosMenu li span {
font: 700 11px/40px"open sans";
color: #fff;
padding-left: 15px;
background: #003a57;
width: 240px;
height: 40px;
display: inline-block;
text-transform: uppercase;
box-sizing: border-box;
}
.produtosSubmenu {
padding: 5px 20px 5px 20px;
display: none;
}
.produtosSubmenu li {
font: 400 16px/16px"open sans";
color: #16232e;
}
.produtosSubmenu li:hover {
font: 600 16px/16px"open sans";
color: #006ba1;
}
<ul class="produtosMenu margin-top-45">
<li page="produtos/componentes-plasticos-diversos/" family="16" class="father plus">
<span class="produtosMenuClick">Componentes Plásticos Diversos</span>
</li>
<li page="produtos/componentes-plasticos-diversos/teste-1/" family="16" children="38" class="son1 plus">
<ul style="display: none;" class="produtosSubmenu">
<li onclick="window.location='/produtos/componentes-plasticos-diversos/teste-1/'">
<a href="/produtos/componentes-plasticos-diversos/teste-1/">Teste 1</a>
</li>
</ul>
</li>
<li page="produtos/espelhos-retrovisores/" family="14" class="father plus">
<span>Espelhos Retrovisores</span>
</li>
<li page="produtos/espelhos-retrovisores/teste-2/" family="14" children="39" class="son1 plus">
<ul style="display: none;" class="produtosSubmenu">
<li onclick="window.location='/produtos/espelhos-retrovisores/teste-2/'">
<a href="/produtos/espelhos-retrovisores/teste-2/">Teste 2</a>
</li>
</ul>
</li>
</ul>
When I click on span
Various Plastic Components, he has to show the ul
that’s below it, it’s okay, it works, what happens is that the click fires on all the elements.
I mean, when I click Various Plastic Components he does the fadeToggle on the other li
Mirrors and Mirrors.
How to fix this?
Oops, dude, I can’t really touch HTML. Yeah, this is automatically generated through PHP. It’s a menu that checks for submenus or not. The way it is, you could click on one?
– Felipe Viero Goulart
Ah understood, sorry then, I will change here to fit your situation;
– Rafael Withoeft
@Felipestoker I will put a new javascript, could test?
– Rafael Withoeft
Of course I do :D
– Felipe Viero Goulart
Rafael, it worked perfectly :D
– Felipe Viero Goulart
@Felipestoker very good :) I am happy
– Rafael Withoeft