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