title: How to fix blinking navbar after click
body: <p>I tried to use this solution (<a href="https://stackoverflow.com/questions/16680543/hide-twitter-bootstrap-nav-collapse-on-click">Hide Twitter Bootstrap nav collapse on click</a>) to hide nav collapse automatically when clicking. It's working correctly when nav is collapsed but when I'm using site on desktops (exactly when nav is not collapsed) nav is blinking. </p>
  
  <p><strong>Code:</strong> </p>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.nav a').on('click', function() {
    $(".btn-navbar").click(); //bootstrap 2.x
    $(".navbar-toggle").click() //bootstrap 3.x by Richard
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.block {
    padding: 70px 0;
  }
  #section-white {
    background-color: #fff;
    height: 100px;
  }
  #section-1 {
    margin-top: 51px;
    /* height of header-navbar */
  }
  #section-1,
  #section-2,
  #section-3 {
    height: 600px;
    background-color: #555;
    color: #fff;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav class="navbar navbar-default navbar-fixed-top" role="navigation"&gt;
    &lt;div class="container"&gt;
      &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
      &lt;div class="navbar-header page-scroll"&gt;
        &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"&gt;
          &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
        &lt;/button&gt;
        &lt;a class="navbar-brand" href="#"&gt;Brand&lt;/a&gt;
      &lt;/div&gt;
  
      &lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
      &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt;
        &lt;ul class="nav navbar-nav navbar-right"&gt;
          &lt;li class="hidden"&gt;
            &lt;a class="page-scroll" href="#page-top"&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a class="page-scroll" href="#section-1"&gt;About&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a class="page-scroll" href="#section-2"&gt;Services&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a class="page-scroll" href="#section-3"&gt;Contact&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
      &lt;!-- /.navbar-collapse --&gt;
    &lt;/div&gt;
    &lt;!-- /.container --&gt;
  &lt;/nav&gt;
  
  &lt;div class="block" id="section-1"&gt;
    &lt;div class="container"&gt;
      &lt;div class="row"&gt;
        Hello World
      &lt;/div&gt;
      &lt;!-- /.row --&gt;
    &lt;/div&gt;
    &lt;!-- /.container --&gt;
  &lt;/div&gt;
  &lt;!-- /.block --&gt;
  
  &lt;div id="section-white"&gt;&lt;/div&gt;
  
  &lt;div class="block" id="section-2"&gt;
    &lt;div class="container"&gt;
      &lt;div class="row"&gt;
        Hello World
      &lt;/div&gt;
      &lt;!-- /.row --&gt;
    &lt;/div&gt;
    &lt;!-- /.container --&gt;
  &lt;/div&gt;
  &lt;!-- /.block --&gt;
  
  &lt;div id="section-white"&gt;&lt;/div&gt;
  
  &lt;div class="block" id="section-3"&gt;
    &lt;div class="container"&gt;
      &lt;div class="row"&gt;
        Hello World
      &lt;/div&gt;
      &lt;!-- /.row --&gt;
    &lt;/div&gt;
    &lt;!-- /.container --&gt;
  &lt;/div&gt;
  &lt;!-- /.block --&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>You can try it here - <a href="https://jsfiddle.net/hwavo6u1/embedded/result/" rel="nofollow noreferrer">Desktop results</a> and this is source code - <a href="https://jsfiddle.net/hwavo6u1/" rel="nofollow noreferrer">source code</a></p>
  
  <p>Earlier I used this solution in Bootstrap 2.3.2 and haven't got any problem.</p>