我有下面的代码来显示标签。当我单击它们而不是页面加载时,这些选项卡起作用(它显示所有选项卡的内容)。我还需要能够通过单击按钮打开页面上的所有第一个/第二个或第三个选项卡(页面上的多个选项卡组)
$("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 .
我也对其他选项卡解决方案持开放态度。