1

我有下面的代码来显示标签。当我单击它们而不是页面加载时,这些选项卡起作用(它显示所有选项卡的内容)。我还需要能够通过单击按钮打开页面上的所有第一个/第二个或第三个选项卡(页面上的多个选项卡组)

$("ul.tabs").each(function() {
    $(this).find('li:first').addClass("active");
    $(this).next('.tab_container').find('.tab_content:first').show();
});

$("ul.tabs li a").click(function() {
    $(".tab_content").hide();
    var cTab = $(this).closest('li');
    cTab.siblings('li').removeClass("active");
    cTab.addClass("active");
    cTab.closest('ul.tabs').nextAll('.tab_container:first').find('.tab_content').hide(); 

    var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active ID content
    return false;
});

jsfiddle .

我也对其他选项卡解决方案持开放态度。

4

2 回答 2

2

http://jsfiddle.net/agBgL/1/

您只需要最初隐藏选项卡内容。

于 2012-06-10T10:26:20.537 回答
0

删除:

.ui-tabs .ui-tabs-panel { display: block; }

参考

于 2013-05-07T19:03:24.557 回答