Run function based on hash tag using jQuery or Javascript
<p>On my site I have user profiles. Each user profile can have a number of tabs which have a javascript function to show the selected tab and hide all other tabs.</p>

<p>What I'm trying to do is allow a group of users called authors to be able to send a link to their profile and when that profile is loaded, show a specific tab.</p>

<p>Take this user's profile:</p>

<pre><code>http://www.findyourgeek.com/jasonward
</code></pre>

<p>I'd like to let this user link to their reviews as follows:</p>

<pre><code>http://www.findyourgeek.com/jasonward#reviews
</code></pre>

<p>I put code in the document.ready function that I thought would work but it doesn't:</p>

<pre><code>if(window.location.hash.toLowerCase() == "reviews")
{
$('#profileAbout').hide();
$('#profileInterests').hide();
$('#profileOnline').hide();
$('#profileArticles').hide();
$('#profileReviews').slideDown();
$('#profileStatistics').hide();
$('#tabsAbout').removeClass('selected');
$('#tabsInterests').removeClass('selected');
$('#tabsOnline').removeClass('selected');
$('#tabsArticles').removeClass('selected');
$('#tabsReviews').addClass('selected');
$('#tabsStatistics').removeClass('selected');
}
</code></pre>

<p>However, when the code runs it does not show the tab. The code that reads the hashtag is correct but it doesn't run the code below it.</p>

<p>Also, that code is defined as <code>$('#tabsReviews a').click()</code> as well.</p>

<p>Any ideas as to why this doesn't work or any better ideas on how to do it better would be appreciated.</p>
