I want to show / hide the div by clicking on it and hiding when clicking on another item, I'm just able to hide when clicking on another item, when clicking on it, I can not hide it.
Example of how the code is
$(document).on('click', '.opener', function() {
let posicao = $(this).index(".opener");
$('.level0.nav-submenu.nav-panel--dropdown.nav-panel').hide();
if ($('.nav-item.level0.nav-' + (posicao+1) + ' ul').is(':visible')) {
$('.nav-item.level0.nav-' + (posicao+1) + ' ul').hide();
} else {
$('.nav-item.level0.nav-' + (posicao+1) + ' ul').show();
}
});
.opener {
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><navid="mainmenu" class="navi opt-fx-fade-inout opt-sb0 opt-sob opt-hide480 centered with-bullets nav-mobile acco nav-mobile-triggerable">
<ul>
<li class="nav-item level0 nav-1">
<span>Datas Especiais</span>
<span class="opener">\/</span>
<ul class="level0 nav-submenu nav-panel--dropdown nav-panel" style="display: none;">
<li class="nav-item classic">
<span>teste1</span></li></ul></li>
<li class="nav-item level0 nav-2">
<span>Ocasiões</span>
<span class="opener">\/</span>
<ul class="level0 nav-submenu nav-panel--dropdown nav-panel" style="display: none;">
<li class="nav-item classic">
<span>teste2</span></li></ul></li>
<li class="nav-item level0 nav-3">
<span>Categorias</span>
<span class="opener">\/</span>
<ul class="level0 nav-submenu nav-panel--dropdown nav-panel" style="display: none;">
<li class="nav-item classic">
<span>test3</span></li></ul></li>
<li class="nav-item level0 nav-4">
<span>Flores</span>
<span class="opener">\/</span>
<ul class="level0 nav-submenu nav-panel--dropdown nav-panel" style="display: none;">
<li class="nav-item classic">
<span>teste4</span></li></ul></li>
</ul>
</nav>