title: Add/Remove class based on active URL
body: <p>My HTML code looks like this:</p>
  
  <pre><code>&lt;div id="sidebar-menu" class="main_menu_side hidden-print main_menu"&gt;
      &lt;div class="menu_section"&gt;
          &lt;ul class="nav side-menu"&gt;
              &lt;li&gt;
                  &lt;a&gt;
                      &lt;i class="fa fa-home"&gt;&lt;/i&gt;home
                      &lt;span class="fa fa-chevron-down"&gt;&lt;/span&gt;
                   &lt;/a&gt;
                   &lt;ul class="nav child_menu" style="display: none"&gt;
                       &lt;li&gt;
                          &lt;a href="testing2.php"&gt;Dashboard&lt;/a&gt;
                       &lt;/li&gt;
                       &lt;li&gt;
                           &lt;a href="testing2.php#x-test"&gt;dashbord2&lt;/a&gt;
                       &lt;/li&gt;
                   &lt;/ul&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;a&gt;
                      &lt;i class="fa fa-edit"&gt;&lt;/i&gt;form
                      &lt;span class="fa fa-chevron-down"&gt;&lt;/span&gt;
                  &lt;/a&gt;
                  &lt;ul class="nav child_menu" style="display: none"&gt;
                      &lt;li&gt;
                          &lt;a href="genform.php"&gt;general form&lt;/a&gt;
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;a href="formval.php"&gt;form validation&lt;/a&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>to add/remove class based on current url, i am using this:</p>
  
  <pre><code>$(function () {
      var url = window.location.href;
      $('#sidebar-menu a[href="' + url + '"]').parent('li').addClass('current-page');
      $('#sidebar-menu a').filter(function () {
          return this.href == url;
      }).parent('li').addClass('current-page').parent('ul').slideDown().parent().addClass('active');
  });
  </code></pre>
  
  <p>It works, but when i click this link</p>
  
  <pre><code>&lt;a href="testing2.php#x-test"&gt;dashbord2&lt;/a&gt;
  </code></pre>
  
  <p>the class="current-page" doesn't change to current path url<br />
  How i fix this?</p>