How to stop the Timer in Javascript?

 Posted by vishalneeraj-24503 on 12/20/2013 | Category: JavaScript Interview questions | Views: 848 | Points: 40
Answer:

The clearInterval() static method of window class is used to stop timer of the function specified in the setInterval() method.

For Example:-
<script type="text/javascript">

var str = setInterval(function(){start_timer()},3000);

function start_timer()
{
alert("Hello");
}

function stop_timer()
{
window.clearInterval(str);
}
</script>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response