2010-07-06 63 views

回答

1

使用tuturial作为源,可以

setInterval(function(){ 
    if ($('a.selected').next().length) 
     $('a.selected').next().click(); 
    else 
     $('a[rel=panel]').first().click(); 
},2000); 

demo

+0

感谢您的答复,我试图实现这一点,但它似乎没有不正在工作 - http://jsfiddle.net/GFphT/1/ - 任何想法?非常感谢! – Probocop 2010-07-06 09:24:30

+0

我对你的代码进行了一些修改以适应... http://jsfiddle.net/GFphT/10/你可以在JS中看到我为修改所做的// [更改],而且活动类应该放在现在在李的这里看,http://fiddle.jshell.net/GFphT/10/show/light/ – Reigel 2010-07-06 10:00:02

+0

这是一流的,非常感谢你的帮助! – Probocop 2010-07-06 10:16:35

0

有该网页上的每一次点击处理函数定义一个函数:

$('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);