2011-09-06 23 views
0

iam使用jquery定時器http://jquery.offput.ca/timers/創建文檔在每5秒和暫停和恢復控制按鈕。這裏是我的腳本:令人困惑的關於jquery定時器

$(function() { 
      $('.handler').load("../Pages/csFetchCustomer.ashx?"); 
      $('.controlled-interval').everyTime(5000, 'controlled', function() { 
       $('.handler').load("../Pages/csFetchCustomer.ashx?"); 
       $('.stop').click(function() { 
        $('.controlled-interval').stopTime('controlled'); 
       }); 
      }); 
     }); 

用這個腳本,我已經創建文件,加載每5秒暫停按鈕controll ,. 但如何創建簡歷/播放按鈕控件? 任何建議,歡迎 謝謝。

回答

1

有在其網站上演示的工作是做你想要什麼,但這裏是我的簡化代碼:

$(document).ready(function() { 
    var active = true, 
     runLoadEvery = function() { 
      $('.controlled-interval').everyTime(5000, 'controlled', function() { 
       $('.handler').load("../Pages/csFetchCustomer.ashx?");      
      }); 
     }; 
    // start running as soon as ready event is fired 
    runLoadEvery(); 

    $('.start').click(function() { 
     active = true; 
     runLoadEvery(); 
    }); 
    $('.stop').click(function() { 
     active = false; 
     $('.controlled-interval').stopTime('controlled'); 
    }); 
}); 
+0

完美地工作..感謝了很多WTK。你的腳本很容易理解。 – syads321

+0

只是好奇,如何運行runLoadEvery();文檔準備事件中的函數?或者可能有任何文件可以說明這一點?不管怎樣,謝謝。 – syads321

+0

我已經更新了我的答案。 – WTK