Link to JQuery Tab from within page content
<p>I'm building an application that is using JQuery to created tabbed content on the homepage.</p>

<p>I'm using this example of code to build on.
<a href="http://jqueryfordesigners.com/jquery-tabs/" rel="nofollow">http://jqueryfordesigners.com/jquery-tabs/</a></p>

<p>This all works great however how can I link to a tab so that it acts the same as clicking the tabbed links from within any content on the homepage or site?</p>

<p>My Javascript code.</p>

<pre><code>$(document).ready(function(){
var tabContainers = $('div.tabs &gt; div');

$('div.tabs ul.tabNavigation a').click(function () {
    tabContainers.hide().filter(this.hash).show();

    $('div.tabs ul.tabNavigation a').removeClass('selected');
    $(this).addClass('selected');

    return false;
}).filter(':first').click();
</code></pre>

<p>});</p>

<p>My HTML.</p>

<pre><code>    &lt;div class="tabs"&gt;
  &lt;!-- tabs --&gt;
  &lt;ul class="tabNavigation"&gt;
    &lt;li&gt;&lt;a href="#tab1"&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#tab2"&gt;Tab 2&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#tab3"&gt;Tab 3&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#tab4"&gt;Tab 4&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;

  &lt;!-- tab containers --&gt;
  &lt;div id="tab1"&gt;
    ...
  &lt;/div&gt;
  &lt;div id="tab2"&gt;
    ...
  &lt;/div&gt;
  &lt;div id="tab3"&gt;
    ...
  &lt;/div&gt;
  &lt;div id="tab4"&gt;
    ...
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I thought I could do something link</p>

<pre><code>&lt;a href="#tab3"&gt;My link text&lt;/a&gt;
</code></pre>

<p>in my content but I'm assuming i need to make same addition to the javascript code to make this work.</p>

<p><strong>EDIT</strong>
I'ved added the following code to my javascript however I the tab I clicked doesn't get the selected css rule.</p>

<pre><code>    // add code for links to tabs
$('a.tablink').click(function (){

    tabContainers.hide().filter(this.hash).show();

    $('div.tabs ul.tabNavigation a').removeClass('selected');
    $(this.hash).addClass('selected');

    return false;
})
</code></pre>

<p>What do I need to change here
    $(this.hash).addClass('selected');
to add the css class .selected</p>
