jquery选项卡选择

jquery代码是这样的:

$(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); 

和标签:

   

每当页面加载时,第一个标签打开第一个。 但如果我想要第二个标签显示,那我该怎么做呢。 喜欢从一个函数内部加载页面如:window.location =“display.php”; 加载时我想要第二个标签打开怎么做? 如果我想要第一个标签显示如何做到这一点,还来自另一个function?

提前致谢..

像这样做,

 $(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content var index = $("ul.tabs li.active").show().index(); $(".tab_content").eq(index).show(); //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); 

然后在html上的选项卡( li )上设置一个活动状态,