We have seen how to call again and again a function at a time interval by using setInterval() method . Now we will learn how to stop this setInterval by using clearInterval() method in JavaScript. Here is the code
We have used setInterval() and clearInterval() and developed this code which display the current time on click of Start button and stops displaying on click of Stop button. Here is the code.

<title>Page Title here</title>
<script language=javascript>

function to_start(){

function to_stop(){

function disp(){
var dt= new Date();
var str=dt.toTimeString()

<body >

<input type=text id=n1 >
<input type="button" name="btn" value="Start" onclick="to_start()";>
<input type="button" name="btn" value="Stop" onclick="to_stop()";>


Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer