Mobile menu does not close when you click

Asked

Viewed 928 times

0

People would like to know if it is possible to close the mobile menu when clicking the link because when I expand 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 and onepage

Follow my menu closing code after 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 close menu but it doesn’t work because

  • Tried slideup and slideDown?

  • 1

    $(Document). ready(Function() { $('.Nav .link').click(Function() { $('.Nav-Collapse').slideup(); }); });

  • our guy vlw if uder answer the question I already mark as answer thank you

  • For nothing Kirito! I already entered the answer, thanks!

1 answer

2


Use slideup and slideDown:

$(Document). ready(Function() { $('. Nav . link'). click(Function() { $('.Nav-Collapse'). slideup(); }); });

Browser other questions tagged

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