Window clearInterval() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window clearInterval


The clearInterval() method clears a timer set with the setInterval() method.

Parameter Values

Parameter Description
id_of_setinterval Required. The ID of the timer returned by the setInterval() method

Return Value:

No return value

The following code shows how to Display the current time as a clock.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<p id="demo"></p>

<button onclick="myStopFunction()">Stop time</button>

var myVar = setInterval(function(){ myTimer() }, 1000);

function myTimer() {//  w  w w  .  ja  v a2s .  c o m
    var d = new Date();
    var t = d.toLocaleTimeString();
    document.getElementById("demo").innerHTML = t;

function myStopFunction() {


Related Tutorials