Jquery show content in tabs
<p>I need to show different content in two tabs.
My code check a variable to understand, after a reloading page, which is the variable value and then show the correct tab.</p>

<p>This is my code:</p>

<pre><code>&lt;div id="tabs_container"&gt;
        &lt;ul id="tabs"&gt;
            &lt;?php 
                if($type==1): 
            ?&gt;
                &lt;li class="active"&gt;
                    &lt;a id="tab_one" href="#one"&gt;&lt;/a&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;a id="tab_two" href="#two"&gt;&lt;/a&gt;
                &lt;/li&gt;              

            &lt;?php 
                else: 
            ?&gt;
                 &lt;li&gt;
                    &lt;a id="tab_one" href="#one"&gt;&lt;/a&gt;
                &lt;/li&gt;
                 &lt;li class="active"&gt;
                    &lt;a id="tab_two" href="#two"&gt;&lt;/a&gt;
                &lt;/li&gt;
            &lt;?php endif; ?&gt;
        &lt;/ul&gt;
    &lt;/div&gt;

    &lt;div id="tabs_content_container"&gt;   
        &lt;div id="one" class="tab_content" &gt;
            show content 1
        &lt;/div&gt;      
        &lt;div id="two" class="tab_content" &gt;
           show content 2
        &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>So when <code>$type</code>equals 1 the <code>li</code>of tab_one has an <code>active</code> class otherwise the tab_two has the active class.
This is my jquery code to change the tabs.
This code work perfectly at the first loading of the page, it loads correctly the tab_one and if you click on the tab_two it shows the correct content.
But this code doesn't work if I reload the page with <code>$type=2</code></p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function(){
        //  When user clicks on tab, this code will be executed

        $("#tabs li").click(function() {
            //  First remove class "active" from currently active tab
            $("#tabs li").removeClass('active');

            //  Now add class "active" to the selected/clicked tab
            $(this).addClass("active");         

            //  Hide all tab content
            $(".tab_content").hide();

            //  Here we get the href value of the selected tab
            var selected_tab = $(this).find("a").attr("href");          

            //  Show the selected tab content
            $(selected_tab).fadeIn();

            //  At the end, we add return false so that the click on the link is not executed
            return false;
        });

    });
&lt;/script&gt;
</code></pre>

<p>How can I modify my jquery code to show the correct content? Something that doen't required the click function...
Thanks</p>
