JQuery Timers plug-in URL: http://plugins.jquery.com/project/timers
The JQuery Timers application provides three functions. 1. everyTime (interval, [Timer name], function name, [number limit], [wait for the function program to complete]) 2. oneTime (interval, [Timer name], call function) 3. stopTime ([Timer name], [function name]) /*************************************** * ********************** everyTime (time interval, [Timer name], function name, [frequency limit], [waiting for function completion]) **************************************** * ******************* // execute the test () function every 1 second () function test () {// do something ...} $ ('body '). everyTime ('1s', test); // execute $ ('body') every 1 second '). everyTime ('1s ', function () {// do something ...}); // execute every 1 second and name the Timer A $ ('body '). everyTime ('1s ', 'A', function () {// do something ...}); // execute every 20 seconds, up to 5 times, and name the timer as B $ ('body '). everyTime ('2das ',' B ', function () {// do something ...}, 5); // execute every 20 seconds, unlimited times, and name the timer as C // if the time interval reaches, however, if the function program is still not completed, you need to wait until the execution function is completed before timing $ ('body '). everyTime ('2das ', 'C', function () {// run a program that will take more than 20 seconds}, 0, true ); /*************************************** * ******************** oneTime (time interval, [Timer name], call function) **************************************** * ***************** // execute $ ('body') after the last 10 seconds '). oneTime ('1das ', function () {// do something ...}); // execute the task in the last 100 seconds and name the timer D $ ('body '). oneTime ('1hs ', 'D', function () {// do something ...}); /*************************************** * ********************* stopTime ([Timer name], [function name]) **************************************** * ******************* // stop all objects in the $ ('body ') upper timer $ ('body '). stopTime (); // stop $ ('body') indicates A timer $ ('body '). stopTime ('A'); // stop the timer $ ('body') for all calls to test () on $ ('body '). stopTime (test); custom time unit open source code find powers: {// Yeah this is major overkill... 'ms': 1, 'cs ': 10, 'ds': 100,'s': 1000, 'da': 10000, 'hs ': 100000, 'ks ': 1000000}
Example:
Html code
<Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type = "text/javascript"> </script>
<Script src = "http://files.cnblogs.com/dachie/jquery.timers-1.2.js" type = "text/javascript"> </script>
<Script>
Function check (){
$ ("# Button1"). attr ("disabled", true );
$ ("# Button1"). val ("submitting. Please wait for 3 seconds .....");
$ ('Body'). oneTime ('3s ', function (){
$ ("# Button1"). attr ("disabled", false );
$ ("# Button1"). val ("test submitted ");
});
}
</Script>
<Input id = "Button1" onclick = "check (); return false;" value = "test submission" type = "submit" name = "Button1">