title: How to change the active class on scroll in bootstrap using jquery?
body: <p>Its a landing page so all navigation link represent a section on same page.</p>
  
  <p>My navbar</p>
  
  <pre><code> &lt;nav class="navbar navbar-default navbar-fixed-top"&gt;
          &lt;div class="container-fluid"&gt;
            &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
            &lt;div class="navbar-header"&gt;
              &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"&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 Name&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="active"&gt;&lt;a href="#home"&gt;Home&lt;/a&gt;&lt;/li&gt;  
                &lt;li&gt;&lt;a href="#about"&gt;About Us&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#choose"&gt;Why This Company&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#mission"&gt;Mission and Vision&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#services"&gt;Services&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#"&gt;How it Works&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#destination"&gt;Destination&lt;/a&gt;&lt;/li&gt; 
                &lt;li&gt;&lt;a href="#associate"&gt;Associate Partners&lt;/a&gt;&lt;/li&gt;             
                &lt;li&gt;&lt;a href="#contact"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; 
              &lt;/ul&gt;
            &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
          &lt;/div&gt;&lt;!-- /.container-fluid --&gt;
        &lt;/nav&gt;
  </code></pre>
  
  <p>On click its changing the active class using jquery</p>
  
  <pre><code>        $(document).ready(function () {
      $('.nav li a').click(function(e) {
  
          $('.nav li').removeClass('active');
  
          var $parent = $(this).parent();
          if (!$parent.hasClass('active')) {
              $parent.addClass('active');
          }
      });
  });
  </code></pre>
  
  <p><strong>I am not able to do it on scroll. Each nav link represents a section on that same page.</strong></p>
  
  <p>Thanks.</p>