我用下面的教程创建我的主页一个特色内容滑块 - http://www.queness.com/post/274/jquery-sliding-tab-menu-for-sidebar-tutorialjQuery的选项卡中修改自动滚动
什么,我虽然不知道,我将如何去有关的代码自动滚动修改到下一个标签几秒后?我假设我需要setInterval
并触发该功能内的某些内容,但我无法完全弄明白。
任何帮助将不胜感激! 感谢
我用下面的教程创建我的主页一个特色内容滑块 - http://www.queness.com/post/274/jquery-sliding-tab-menu-for-sidebar-tutorialjQuery的选项卡中修改自动滚动
什么,我虽然不知道,我将如何去有关的代码自动滚动修改到下一个标签几秒后?我假设我需要setInterval
并触发该功能内的某些内容,但我无法完全弄明白。
任何帮助将不胜感激! 感谢
使用tuturial作为源,可以
setInterval(function(){
if ($('a.selected').next().length)
$('a.selected').next().click();
else
$('a[rel=panel]').first().click();
},2000);
有该网页上的每一次点击处理函数定义一个函数:
$('a[rel=panel]').click(function() {
//Get the height of the sub-panel
var panelheight = $($(this).attr('href')).height();
//Set class for the selected item
$('a[rel=panel]').removeClass('selected');
$(this).addClass('selected');
//Resize the height
$('#mask').animate({'height':panelheight},{queue:false, duration:500});
//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
$('#mask').scrollTo($(this).attr('href'), 800);
//Discard the link default behavior
return false;
});
所以,最简单的方法来触发某个选项卡会(第一个面板)$("#panel-1 ").triggerHandler("click");
您要每个选项卡滚动到。
这会做:
var amount = 1;
setInterval(function(){
$("#panel-"+amount).triggerHandler("click");
if(amount == 4)
amount = 1;
}, 1000);
感谢您的答复,我试图实现这一点,但它似乎没有不正在工作 - http://jsfiddle.net/GFphT/1/ - 任何想法?非常感谢! – Probocop 2010-07-06 09:24:30
我对你的代码进行了一些修改以适应... http://jsfiddle.net/GFphT/10/你可以在JS中看到我为修改所做的// [更改],而且活动类应该放在现在在李的这里看,http://fiddle.jshell.net/GFphT/10/show/light/ – Reigel 2010-07-06 10:00:02
这是一流的,非常感谢你的帮助! – Probocop 2010-07-06 10:16:35