title: Bootstrap navbar active class
body: <p>I try to use jquery to initialize active class from navigation, but so far it works only if there's nothing else after the menu item in url.</p>
  
  <p>For ex, if i go on users <code>site.com/users</code> the code works, but when i browse the controller and i give it parameters it disappears ex <code>site.com/users/param1/param2</code></p>
  
  <p>below you can see my code:</p>
  
  <pre><code>$(document).ready(function () {
      var url = window.location;
      // Will only work if string in href matches with location
      $('ul.nav a[href="' + url + '"]').parent().addClass('active');
  
      // Will also work for relative and absolute hrefs
      $('ul.nav a').filter(function () {
          return this.href == url;
      }).parent().addClass('active').parent().parent().addClass('active');
  });
  </code></pre>