title: Jquery, activate script if hashtag on end of URL matches a class name
body: <p>Hey folks. I am using a little bit of jQuery to do a live sort of my portfolio when various categories are selected. Basically, the script matches the content of an <code>&lt;li&gt;</code> tag on click (my menu) with the class names of other <code>&lt;li&gt;</code> tags elsewhere on the page. The result is the portfolio items match the nav clicked will show and hide the rest. A live sort. However, i want to add the ability to add a permalink to activate the jquery to sort by a hashtag at the end.. for example: <code>work.html#category1</code> would automatically set the script to hide everything but category one. My script and basic page setup is below. Any help would be greatly appreciated!</p>
  
  <pre><code> &lt;script&gt;
      $(document).ready(function() {
          $('#worknavwrap p a').click(function() {
              $(this).css('outline','none');
              $('ul#worknavwrap .current').removeClass('current');
              $(this).parent().addClass('current');
  
              var filterVal = $(this).text().toLowerCase().replace(' ','_');
  
              if(filterVal == 'all') {
                  $('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
              } else {
  
                  $('ul#portfolio li').each(function() {
                      if(!$(this).hasClass(filterVal)) {
                          $(this).fadeOut('normal').addClass('hidden');
                      } else {
                          $(this).fadeIn('slow').removeClass('hidden');
                      }
                  });
              }
  
              return false;
          });
      });
      &lt;/script&gt;
      &lt;ul id="worknavwrap"&gt;
        &lt;li&gt;&lt;a href="#category1"&gt;Category 1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#category2"&gt;Category 2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="#category3"&gt;Category 3&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul id="portfolio"&gt;
        &lt;li class="category1"&gt;Item 1&lt;/li&gt;
        &lt;li class="category1"&gt;Item 2&lt;/li&gt;
        &lt;li class="category2"&gt;Item 3&lt;/li&gt;
        &lt;li class="category1"&gt;Item 4&lt;/li&gt;
        &lt;li class="category3"&gt;Item 5&lt;/li&gt;
        &lt;li class="category3"&gt;Item 6&lt;/li&gt;
        &lt;li class="category2"&gt;Item 7&lt;/li&gt;
        &lt;li class="category1"&gt;Item 8&lt;/li&gt;
      &lt;/ul&gt;
  </code></pre>