What is the method for JavaScript to delete the delayer
This article mainly explains "what is the method of JavaScript deletion delay timer". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of JavaScript deletion delay timer".
JavaScript delete the delay: 1, use the "clearInterval (id)" statement, you can delete the delay defined by setInterval (); 2, use the "clearTimeout (id)" statement, you can delete the delay defined by setTimeout ().
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
JavaScript timers, also known as timers, sometimes referred to as "timers", are used to perform certain tasks after a specified period of time, similar to the alarm clock in our lives.
In JavaScript, we can use delays to delay the execution of some code, or to repeat some code at regular intervals.
There are two ways to set timers in JavaScript, namely setTimeout () and setInterval (), and there are also two ways to delete delayers:
ClearInterval () cancels the timeout set by setInterval ().
ClearTimeout () cancels the timeout set by the setTimeout () method.
ClearInterval ()
The clearInterval () method cancels the timeout set by setInterval ().
Syntax:
ClearInterval (id)
The argument to the clearInterval () method must be the ID value returned by setInterval ().
Example:
Var int=self.setInterval ("clock ()", 50) function clock () {var t=new Date () document.getElementById ("clock") .value=t}