Mobile menu does not close when you click

0

I would like to know if it is possible to close the mobile menu when clicking the link because when it expands the menu it opens normally after I click on the link it goes to anchor that I created but the menu remains open covering the content on the site NOTE: the site is onepage

Follow my code to close the menu after the click html:

 <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                {{--<a class="navbar-brand" href="#"><img src="{{ asset('img/logo-menu.png') }}" class="img-responsive logo" alt="jetwash"></a>--}}
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-left">
                    <li class="list"><a href="#home" class="scroll link">Home</a></li>
                    <li class="list"><a href="#about" class="scroll link">Sobre</a></li>
                    <li class="list"><a href="#services" class="scroll link">Serviços</a></li>
                    <li class="list"><a href="#franchise" class="scroll link">Franquia</a></li>
                    <li class="list"><a href="#midia" class="scroll link">Mídia</a></li>
                    <li class="list"><a href="#contact" class="scroll link">Contato</a></li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>

js:

$(document).ready(function () {
    $('.nav .link').click(function() {
        $('.nav-collapse').collapse('hide');
    });
});

I created this jquery code to make the menu close but it does not work because

    
asked by anonymous 09.09.2016 / 21:44

1 answer

2

Use slideUp and slideDown:

$ (document) .ready (function () {   $ ('. nav .link'). click (function () {    $ ('. nav-collapse'). slideUp ();   });  });

    
13.10.2016 / 04:03