Bootstrap Navigation Close in Mobile View Single Page

  // To close navigation in single page in Bootstrap
    $(".navbar-nav li a").click(function () {
        if ($('.navbar-collapse').hasClass("in")) {
            $('.navbar-collapse').addClass("collapse");
            $('.navbar-collapse').removeClass("in");
            $('.navbar-collapse').css('height', 'auto');
        }
        else {
            $('.navbar-collapse').removeClass("collapse");
            $('.navbar-collapse').addClass("in");
            $('.navbar-collapse').css('height', '0');
        }

        $('.navbar-collapse').css('height', '0');
    });

/**********************************OR***********************************/

$('.navbar-nav a').on('click', function () {
        $(".btn-navbar").click(); //bootstrap 2.x
        $(".navbar-toggle").click() //bootstrap 3.x by Richard
    });

Comments

Popular posts from this blog

Scroll After Fixed Navigation

Bootstrap CSS Customize with SCSS CSS

Best way to prevent page scrolling on drag (mobile)