Questions tagged [clearinterval]

The Javascript clearInterval() method clears a timer set with the setInterval() method.

The Javascript clearInterval() method clears a timer set with the setInterval() method.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method.

660 questions
6
votes
2 answers

Executing code after clearInterval

I have a setInterval calling a loop which displays an animation. When I clearInterval in response to a user input, there are possibly one or more loop callbacks in queue. If I put a function call directly after the clearInterval statement, the…
mshang
  • 955
  • 4
  • 11
  • 18
6
votes
1 answer

Web workers to make setInterval work as normal

I'm trying to create an automated program by using javascript console only. I need to use setInterval to make a loop for my program. The relevant part of the code is just like this: refreshIntervalId=setInterval(tick,500); So the "tick" function…
6
votes
1 answer

How to stop a timer function from running?

I'm a bit new to js and have been trying to figure out how to stop this function from running when I click on a button. I tried using clearInterval but I am not sure I am doing it properly. Can someone take a look at this code and point me in the…
isognomon
  • 75
  • 1
  • 1
  • 7
6
votes
1 answer

Javascript setTimeout not stopping on clearInterval()

How do you stop a timer when clearInterval() does not stop it? The purpose of this code is to animate a number from 0 upwards until it reaches the end (eg animate from 0... 75%). But the timer does not stop when I call clearInterval():…
JK.
  • 21,477
  • 35
  • 135
  • 214
5
votes
1 answer

jquery to disable form elements

Scenario is that I have written a function for auto refresh on form element and I want onclick event on login button to disable the auto refresh function. I'm not able to get disable the autorefresh and the page still refreshes. My code…
anu
  • 59
  • 1
  • 2
  • 4
5
votes
1 answer

Simple Javascript or jQuery clearInterval problem

I have gone through most of the code here and tried several ways to get clearInterval to work and for some reason it is just not working, although it is a basic and simple problem. Here is the code and I want to know WHY it isn't working, not just…
user688079
5
votes
1 answer

Clear interval in React class

So, we have this simple React component that receives an integer from the father component. When the button is clicked, we display the integer on the screen and the countdown begins. The question is how can I stop the countdown. While reading other…
Darmaiad
  • 53
  • 1
  • 4
5
votes
4 answers

clearInterval() not working on clock timer with JavaScript

I am very new to JavaScript and programming in general. I am currently in a little pickle with some code that I am playing around with, and I am wondering if anyone can give me some advice. Background: The code I am working with is rather simple;…
5
votes
3 answers

jQuery: Stop and start "setInterval"

I have a slideshow on my website but there is a problem with in. Here, my JS: var size_ini = 1; $(document).ready(function() { setInterval('$("#next").click()',10000) $("#next").click(function() { if(size_ini < 3); …
user2628521
5
votes
2 answers

Javascript, toggle a setInterval

I'm trying to make a small script where the screen will randomly change it's background color every 100ms, and you can toggle this on and off by pressing a single button. I can get it to start, but I can't get it to stop. Here is the main code for…
damon
  • 2,687
  • 8
  • 25
  • 35
5
votes
5 answers

How to stop timer after ten seconds in javascript using setInterval and clearInterval?

I was wondering how can I stop a timer after ten seconds in javascript using setInterval and clearInterval?? Here's my code example, could you please tell me where I'm going wrong: