You are here: Reference > JavaScript > client-side > HTML DOM > methods > clearInterval (window)

clearInterval method (window)

Browser support:
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.


object.clearInterval (intervalID);
You can find the related objects in the Supported by objects section below.


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:
    <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);
            document.getElementById ("output").innerHTML += number;
    <button onclick="StartCounter ();">Click to count!</button>
    <textarea id="output"></textarea>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content