开发者

jQuery Tabs - default tab problem

I use the following jQuery code to display my tabbed interface. My problem is that the default tab is hard-coded. If I submit a form from any of the tabs, it always defaults back to the default tab.

Can this be changed somehow? Using sessions? If yes, how to use sessions with jQuery?

$(document).ready(function() {
    //Default Action
    $(".tab_content").hide();
    $("ul.tabs li:nth-child(2)").addClass("active").show开发者_开发问答();
    $(".tab_content:nth-child(2)").show();

    //On Click Event
    $("ul.tabs li").click(function() {
        $("ul.tabs li").removeClass("active");
        $(this).addClass("active");
        $(".tab_content").hide();
        var activeTab = $(this).find("a").attr("href");
        if ($.browser.msie)
        { $(activeTab).show(); }
        else
        { $(activeTab).fadeIn(); }
        return false;
    });
});


You can use a hidden field like brum said or pass it to your URL (GET).

After you can take it with: http://www.onlineaspect.com/2009/06/10/reading-get-variables-with-javascript/

or if it's a PHP page:

<script type="text/javascript">
    var _GET = <?php echo json_encode($_GET); ?>
</script>

After, you just need to activate the right tab.


You could use a hidden field and write the selected tab into this. Using this value to set the selected tab....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜