clearInterval method (window)
Clears the periodically repeated action that was previously set by the setInterval method.
If the action was registered with the setTimeout method, use the clearTimeout method to remove it.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. Integer that specifies the identifier of the timer returned by the setInterval method. |
Return value:
This method has no return value.
Example HTML code 1:
This example illustrates the use of the clearInterval method:
|
||||
<head> <script type="text/javascript"> var number = 0; var timerID = null; function StartCounter () { if (timerID === null) { // to avoid multiple registration timerID = setInterval (DisplayNumber, 200); } } function DisplayNumber () { if (number > 9) { clearInterval (timerID); return; } document.getElementById ("output").innerHTML += number; number++; } </script> </head> <body> <button onclick="StartCounter ();">Click to count!</button> <textarea id="output"></textarea> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments