I would like when I clicked on an item with a submenu, whatever was active would hide.
I found a script similar to mine, but I had difficulty adapting.
I'm using the following script for the subclass with onclick
Javascript for DropDown
var $j = jQuery.noConflict();
$j(".abre-dropdown").click(function(){
$j(this).children("ul").slideToggle();
})
$j("ul").click(function(p){
p.stopPropagation();
})
var $ = jQuery.noConflict();
var checkbox = $('#btn-menu');
$('body').click(function() {
checkbox.prop("checked", false);
});
$('#btn-menu, .menuMobile, .barra-menu').click(function(event) {
event.stopPropagation();
});
Menu HTML:
<nav class="menuMobile">
<ul>
<li class="item-menu-escuro"><a href="http://<?php echo $url; ?>/home"><label style="float:left;" class="icon-home"></label>Página inicial</a></li>
<li class="abre-dropdown"><a href="javascript:void(0)"><label style="float:left;" class="icon-location"></label>Nossa casa<label class="icon-down-dir"></label></a>
<ul class="submenu-1">
<li class="abre-dropdown"><a href="javascript:void(0)"><label style="float:left;" class="icon-home"></label>Sobre nós<label class="icon-down-dir"></label></a>
<ul class="submenu-2">
<li><a href="http://<?php echo $url; ?>/nossa-casa#terreiro">A casa</a></li>
<li><a href="http://<?php echo $url; ?>/nossa-casa#mae-maria">Mãe Maria C.</a></li>
<li><a href="http://<?php echo $url; ?>/nossa-casa#ogans">Ogans</a></li>
<li><a href="http://<?php echo $url; ?>/nossa-casa#filhos">Filhos</a></li>
</ul>
</li>
<li><a href="http://<?php echo $url; ?>/agenda"><label style="float:left;" class="icon-calendar"></label>Agenda</a></li>
<li><a href="http://<?php echo $url; ?>/localizacao"><label style="float:left;" class="icon-location"></label>Localização</a></li>
<li><a href="http://<?php echo $url; ?>/contato"><label style="float:left;" class="icon-phone"></label>Contato</a></li>
</ul>
</li>
</ul>
</nav>