JavaScript timer use

Source: Internet
Author: User

Application of the Timer

The SetInterval () method that invokes a function or evaluates an expression by the specified period (in milliseconds)
The SetInterval () method keeps calling functions, knowing that clearinterval () is called or the window is closed, and that the ID value returned by setinterval () can be used for the parameters of the Clearinterval () method
SetInterval (CODE,MILLISEC) code to invoke the function or execution, the time interval between the millisec period call or call code (in milliseconds)
Return value: A value that can be passed to Window.clearinterval () to suppress periodic execution of code

<! DOCTYPE html>

SetTimeout () method, which invokes a function or evaluates an expression after a specified number of milliseconds
SetTimeout (CODE,MILLISEC) code to execute, millisec the number of milliseconds to wait before executing the code
Note: setTimeout () executes code only once, and if multiple calls are made, use setinterval () or let code itself call SetTimeout ()

Cleartimeout (id_of_settimeout) cancels setTimeout () set timeout, id_of_settimeout is the ID returned by setTimeout ()

<!     DOCTYPE html>//setTimeout () test Example        vari = 0; varT; functionTime5 () {T= SetTimeout (function() {Console.log (i++);        Time5 (); },1000); }    functionStop () {cleartimeout (t); Console.log ("Okl");    } time5 (); </script>

JavaScript timer use

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.