How to close the menu by clicking the links

0

Good morning, for the mobile menu of my site, I made this model:

Thesiteisonepage,andwhenIclickon"contacts", the page goes down, but the menu is still open ... How do I when to click on any menu item, the menu will 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();
});
    
asked by anonymous 26.12.2017 / 13:21

1 answer

0

Well, I did it ... This was my menu

<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>

.

$(".btn-menu").click(function(){
$(".menu").show();
});
$(".btn-close").click(function(){
$(".menu").hide();
});

$(".fotodomenuz").click(function(){
$(".menu").show();
});

I just put this code below, in my js file.

$('#menuesquerda a').click(function(){ $('.menu').hide(); });
$('#menudireita a').click(function(){ $('.menu').hide(); });
    
26.12.2017 / 15:27