HTML DOM clearInterval() Method
Complete Window Object Reference
Definition and Usage
The clearInterval() method cancels a timeout that is set with the setInterval() method.
The ID value returned by setInterval() is used as the parameter for the
clearInterval() method.
Syntax
clearInterval(id_of_setinterval)
|
Example
The following example calls the clock() function every 50 millisecond. It
also have a button to stop the clock:
<html>
<body>
<input type="text" id="clock" size="35" />
<script language=javascript>
var int=self.setInterval("clock()",50)
function clock()
{
var t=new Date()
document.getElementById("clock").value=t
}
</script>
</form>
<button onclick="int=window.clearInterval(int)">
Stop interval</button>
</body>
</html>
|
Try-It-Yourself Demos
Use
setInterval() and clearInterval()
Complete Window Object Reference
…
|