JQuery _ timer (jQuery Timers) Learning

Source: Internet
Author: User

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">
  •  

     

     

     

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.