2013-12-16 77 views

回答

0

你會使用一個回調的開始。例如:

function stopRoundaboutAfterAWhile() { 
    setTimeout(function() { 
     .roundabout("stopAutoplay"); 
    }, 10000); 
} 

.roundabout(options, stopRoundaboutAfterAWhile) 
0

我的解決方案是在頁面準備就緒並與setTimeout混合時調用自動播放。

此外,我停在隨機秒自動播放和保存在localStorage的股利ID。

$(window).load(function() { 
      $('ul').roundabout(); 
      $('ul').roundabout('startAutoplay'); 

      var tempo = Math.floor(Math.random()*(10000-5000+1))+5000; 

      setTimeout(function(){ 
       $('ul').roundabout('stopAutoplay'); 
      }, tempo); 

      setTimeout(function(){ 
       console.log($('.roundabout-in-focus').attr('id')); 
       window.localStorage.setItem('vilao',$('.roundabout-in-focus').attr('id')); 
      }, tempo + 1000); 

    });