I have a problem that is simple but I do not use JS
at a time so I had a problem.
I'm having to create a menu similar to amazon , but the site is responsive and I've done lists. But it did not look good so I'm doing it with DIVs (if anyone has a better idea, thank you) the problem is this.
When you click on a menu button it opens the div
by the id
of it, but when I click on another it should close the one that was open but I can not close them.
I'm using the following code to stay as light as possible.
JS
$(function(){
$(".btn-toggle").click(function(e){
e.preventDefault();
el = $(this).data('element');
$(el).toggle();
});
});
html
<div id="menu_drop">
<ul class="menu_topo">
<li ><a href="#" ><button type="button" class="btn-toggle" data-element="#minhaDiv">Mídias e Embalagens</button></a></li>
<li><a href="#"><button type="button" class="btn-toggle" data-element="#minhaDiv1">Informática</button></a></li>
<li><a href="#">Eletrônicos</a></li>
<li><a href="#">Telefonia</a></li>
<li><a href="#">Papelaria e Escritório</a></li>
<li><a href="#">Cine e Foto</a></li>
<li><a href="#">Utilidades</a></li>
<li><a href="#">Esporte e Lazer</a></li>
<li><a href="#">Brinquedos</a></li>
</ul>
</div><!-- menu drop-->
<div id="minhaDiv" class="menu_lado">Conteudo</div>
<div id="minhaDiv1" class="menu_lado">Conteudo1</div>