0
Good morning, for the mobile menu of my site, I made this template:
The site is one page, and when I click on "contacts", the page goes down, but the menu remains open... How I do for when click on any menu item, the menu be closed?
I made the menu work with this JS code:
$(".btn-menu").click(function() {
$(".menu").show();
});
$(".btn-close").click(function() {
$(".menu").hide();
});
$(".fotodomenuz").click(function() {
$(".menu").show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<button class="btn-menu"> <i class="fa fa-bars fa-2x" aria-hidden="true"></i> </button>
<div class="menu">
<a class="btn-close"><img src="botao/bottom.png" alt="Botão fechar"></a>
<ul id="menuesquerda">
<a href="#ancora" class="scroll">
<li id="home">Home</li>
</a>
<a href="#seusite" class="scroll">
<li>Portfólio</li>
</a>
</ul>
<ul id="menudireita">
<a href="pages/biografia.html">
<li id="bio">Biografia</li>
</a>
<a href="#footer" class="scroll">
<li>Contatos</li>
</a>
</ul>
</div>
It is impossible to give an exact answer without a minimal, complete and verifiable example. But I think it’s enough to hide the menu in the click event of one of the options
– Artur Trapp
I just need that by clicking on the 'home','portfolio''biography' etc... the menu close... without needing on the "X"
– Lukas Monteiro
How about
<a href="#ancora" onclick="myFunction()">Ancora</a>
anddisplay:none
in the CSS?– hugocsl
Please edit the question and include html
– Caique Romero