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
-2
votes
1 answer

clearInterval "var is undefined" |

I want my timer to stop and reload to 0 when it hits 25 with a clearInterval but it says that the variable refreshInterval is undefined. The timer resets but it keeps on going and I want it completely to stop until its enabled again. function…
umbreonben
  • 33
  • 4
-2
votes
2 answers

javascript async and setInterval for polling

I want most understandable syntax for polling a flag and return when it is true, my code snippet below doesn't work I know, what's the syntax that would make it work if you get my idea ? async function watch(flag) { let id =…
user310291
  • 36,946
  • 82
  • 271
  • 487
-2
votes
1 answer

How to have setInterval start at button press without breaking clearInterval inside function?

I have a setInterval that draws my snake game, and everytime the snake "eats" I have a clearInterval and then the setInterval var with adjusted speed. The original setInterval starts on load. How can I make it start with the press of a button? My…
Meepy
  • 41
  • 5
-2
votes
1 answer

How do I make a element move back and forth with javascript?

So what I have is a black bar that I want to move up and down continuously until I click the stop button. At the moment the black element doesn't move at all, and I'm sure the stop button wouldn't do it's job if it did. I would like the black bar…
-2
votes
1 answer

How to use setInterval and clearInterval as functions

I'm using setInterval with jQuery to change the position of a background-image onLoad but I want to use it as a function so I can call clearInterval to stop it when an element is clicked and to call the function again when another element is clicked…
Fettabachi
  • 79
  • 6
-2
votes
1 answer

Javascript setInterval not returning ID in a timely fashion

I am using Javascript (no JQuery) and have a situation I'm trying to debug. I'm using setInterval with a 1 second interval to monitor physical hardware that is being instructed to move. Once the hardware has moved to the correct position I call…
David Cook
  • 15
  • 5
-2
votes
2 answers

setInterval() still being called after clearInterval()

I have my setInterval function called on click, but after I clear it using an End Timer button it continues to run. It's a countdown clock so I want to make 2 buttons, a reset button and and end button. Both will pretty much do the same thing except…
-2
votes
2 answers

Cancel An Animation With A Click (ClearInteval)

I want to stop my setIntervalby clicking on h1 element which contain stop in its content, but It seems I can't make it happen. I can see value of variable of setInterval which is return in callOff variable on console inside and outside click…
Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58
-2
votes
3 answers

Unable to update the visibility of an html

I am a beginner in ajax/JS/jQuery. I have an ajax call that checks if a file is available on server. To accomplish this I use setInterval() and clearInterval(). I am having trouble in setting the display property to an html element upon successful…
mallya
  • 33
  • 1
  • 7
-2
votes
2 answers

Why clearInterval doesn't work in window blur and focus events functions?

I have a small notification & alert system. I'm just trying to detect if the window's state is blur or focus and then listing these alerts and notifications. But my clearInterval method doesn't work. Here is the code; $(document).ready(function(){ …
-3
votes
1 answer

Why can't I clear this timer in JavaScript?

There is an object. There is this method that initializes the timer in another method within the same object. initstep1() { var totAns = TriviaGame.corAnswered + TriviaGame.incorAnswered; //for (let…
OlegArsyonov
  • 1,251
  • 1
  • 14
  • 18
-3
votes
2 answers

anonymous window.setTimeout function reloading page

Using Tampermonkey to change the behavior of a website. Have some problems with a website with the following code: