How to use Window Object ClearInterval in JavaScript

In this article I am going to explain about window object ClearInterval() method in JavaScript.
  • 1650

JavaScript Window Object ClearInterval() Method

JavaScript ClearInterval() method use for clear the current timer and set SetInterval() method. SetInterval() method is a method by which we can set specifics time interval for any action.

Syntax

 

clearInterval(SetInterval id)

Example

<html>

<head>

    <textarea id="mm"></textarea>

    <script type="text/javascript">

        var int = self.setInterval("Time()", 1000);

        function Time() {

            var date = new Date();

            var tme = date.toLocaleTimeString();

            document.getElementById("mm").value = tme;

        }

    </script>

</head>

<body>

    <button onclick="int=window.clearInterval(int)">

        click me</button>

        <p>click button for setInterval</p>

</body>

</html>

 

Output


setinnn.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.