0
I have a div that when I click on it it shows and hides an ul. With the code like this:
<ul class="homeMenuItens">
<li>
<div pagina='/produtos/incendio' class="homeMenuPai">Incendio</div>
<ul id="incendio" class="homeMenuFilhos" style="display:none">
<li pagina='paginaSYS' onclick='window.location=\"/paginaSYS\"'>tituloMenuSYS</li>
</ul>
</li>
</ul>
Jquery is like this:
$(".homeMenuPai").click(function() {
$(".homeMenuFilhos").css('display','none');
if($(this).parent().find(".homeMenuFilhos").css('display') == 'none'){
$(this).parent().find(".homeMenuFilhos").show();
}
else{
$(this).parent().find(".homeMenuFilhos").hide();
}
});
It’s working, as soon as I click on the Title Menu, for example, it shows the items below. The problem is that if I click Div more than once, it does not hide the items. It only hides when I click the other Divs.
The structure is like this div TITULO ul WITH ITEMS li LIST OF ITEMS
I have 4 equal Ivs
In the image below shows the 4 main menus, if I click on 2, the 1 closes, but if I click on 1 again to close, it does not close.
It would be interesting to create a http://jsfidle.net to show exactly what is happening, so it will be easier to help you
– Erlon Charles
Hi @Erloncharles will get complicated put in jsfidle because the code is full of reserved words, I put an image to facilitate understanding.
– Felipe Viero Goulart
Just to understand you want something here to work like this? http://jqueryui.com/accordion/#Collapsible
– Erlon Charles
@Erloncharles, Vieira helped me the way I needed, thanks. D
– Felipe Viero Goulart