Add an active class to li element if link has a hash tag, then make li element active
<p>I'm new to working with jQuery tabs, and I want to be able to add the functionality of linking directly to a specific tab from outside. Basically everything is working just fine the tab content shows up but the actual tab does not activate, however when you click it, it shows up. I have background images set for the tabs. This is what my css looks like</p>

<pre><code>ul.tabs li a.tab-1 {background-position:0 0;}
ul.tabs li a.tab-1:hover {background-position:0 -61px;}
ul.tabs li.active a.tab-1 {background-position:0 -125px;}
</code></pre>

<p>The active class does not show when you are sent to the link from an outside source.</p>

<pre><code>&lt;ul class="tabs"&gt;
  &lt;li class="active"&gt;&lt;a class="tab-1" href="#tab-1"&gt;history&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a class="tab-2" href="#tab-2"&gt;About&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>Here is rest of jQuery code:</p>

<pre><code>$(document).ready(function() {
  //Default Action
  $(".tab_content").hide(); //Hide all content
  if(location.hash != "") {
    /* If there is a tab id in the page URL */
    $(location.hash).show(); //Show tab content
    $('ul.tabs li:has(a[href="location.hash"])').addClass("active").show(); //Activate tab
    $(this).find("a").addClass("active"); //Add "active” class to href inside selected 
  } else {
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
  }
  //On Click Event
  $("ul.tabs li").click(function() {
    $("ul.tabs li").removeClass("active"); //Remove any "active" class
    $(this).addClass("active"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content
    var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab content
    location.hash = activeTab //Add the anchor to the url (for refresh)
    $(activeTab).fadeIn(); //Fade in the active ID content
    return false;
  });
});
</code></pre>

<p>What I'm trying to achieve is if the url has a specific location:  <code>../../#tab-1</code>
set the li to active and show the active state for the li element.</p>
