Latest web development tutorials

Window clearInterval () method

Window Object Reference Window object

Definition and Usage

clearInterval () method to cancel the the setInterval () timeout settings.

Parameters clearInterval () method must be the ID value returned by the setInterval ().

grammar

clearInterval(id_of_setinterval)


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support clearInterval () method


Examples

Examples

Every 1000 milliseconds call clock () function. clock () function to update the clock. This example also has a button to stop the clock:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
</ Head>
<Body>

<Input type = "text" id = "clock" />
<Script type = "text / javascript">
var int = self.setInterval ( "clock ()", 1000);
function clock () {
var d = new Date ();
var t = d.toLocaleTimeString ();
document.getElementById ( "clock") value = t.;
}
</ Script>
<Button onclick = "int = window.clearInterval (int)"> Stop </ button>

</ Body>
</ Html>

try it"


Window Object Reference Window object