Close mobile menu by clicking scroll

Asked

Viewed 301 times

-1

<header id="header">
        <nav id="main-menu" class="navbar navbar-default navbar-fixed-top" role="banner">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Menu</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.html"><img src="logo.png" alt="Grupo Santiago Administradora" title="Grupo Santiago Administradora"></a>
                </div>

                <div class="collapse navbar-collapse navbar-right">
                    <ul class="nav navbar-nav">
                        <li class="scroll active"><a href="#home">HOME</a></li>
                        <li class="scroll"><a href="#features">DIFERENCIAL</a></li>
                        <li class="scroll"><a href="#services">SERVIÇOS</a></li>
                        <li class="scroll"><a href="#about">QUEM SOMOS</a></li>
                        <li class="scroll"><a href="#get-in-touch">FALE CONOSCO</a></li> 
                        <li class="scroll"> &nbsp; </li>
                        <li class="scroll"><a href="#" target="_blank"><font size="4" color="#00A85A"><strong>2&deg; Via Boleto</strong></font></a></li>
                    </ul>
                </div>
            </div><!--/.container-->
        </nav><!--/nav-->
</header><!--/header-->
  • To get a better sense of what I need the site would be (http://admgruposantiago.com.br) needed that in the menu when accessed via mobile when clicking on a link close the menu and slide to the section, but it scrolls perfectly more the menu is open.

1 answer

0


Add the following script block so that by clicking on a menu link it performs the collapse

$('.navbar-nav a').on('click', function(){
  $('.collapse').toggleClass('in');
});
  • You’re the man!!! Thank you so much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.