jScrollPane和Tabs的示例,几乎一起工作
我希望滚动条(来自jScrollPane)显示每个标签(来自Soh Tanaka)。 目前,它显示第一个选项卡,但它回退到第二个,第三个,第四个选项卡的浏览器默认值…
在这里查看我的实例: jScrollPane和Tabs,几乎一起工作
如何让滚动条显示在每个选项卡上? 谢谢!
jQuery.noConflict(); jQuery(document).ready(function($) { jQuery('.scroll-pane').jScrollPane({ verticalDragMinHeight: 20, verticalDragMaxHeight: 20, horizontalDragMinWidth: 20, horizontalDragMaxWidth: 20 });
});
$(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; });
});
显示每个选项卡后,需要重新初始化jScrollPane。 一个简单的例子:
http://jscrollpane.kelvinluck.com/invisibles.html
在你的情况下你可以尝试:
$("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().jScrollPane(); //Fade in the active ID content and apply jScrollPane return false; });
(我昨天以某种方式将这个答案贴在了错误的问题上 – 很抱歉延迟回答!)