2010-07-06 38 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);