Simple jQuery timer

Providing three functional in the jQuery Timers

  1. Everytime (interval [Timer name], function name, [the number of restrictions], [waiting function completes])
  2. OneTime (interval [Timer Name], the function call)
  3. stopTime ([Timer name], [function name])

everyTime functional

everyTime functional equivalent js cycle timer in
1: execution interval of a second cycle a ()

function a(){
  alert(1); } $('body').everyTime('1s',a); 

2: abbreviated version

$('body').everyTime('1s',function(){ alert(1); }); 

3: performed every second, and a timer designated as A

$('body').everyTime('1s','A',function(){ alert(1); }); 

4: performed every twenty seconds, up to 5 times, and a timer designated as A

$('body').everyTime('20s','A',function(){ alert(1); },5); 

oneTime functional

1: 10s after the execution of the function

$('body').oneTime('1das',function(){ alert(1); }); 

2: 100s perform functions, and a timer designated as A

$('body').oneTime('100s','A',function(){ alert(1); }); 

Functional stopTime

1: Stop all the $ ( 'body') on the timer

$('body').stopTime ();

2: Stop $ ( 'body') A timer on the name

$('body').stopTime ('A');

3: the stop $ ( 'body') all calls a () timer

$('body').stopTime (a);


Author: lilongxi
link: https: //www.jianshu.com/p/6a8ce88c7f02
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.

Guess you like

Origin www.cnblogs.com/mmzz3322/p/11326269.html