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

Unable to clearInterval()

Recently I was working on a stopwatch project in JavaScript. Few things I encountered. First when I assign a variable to the setInterval() function like let sInterval = setInterval(functionName, milliseconds). I was unable to pass it to an…
-1
votes
1 answer

How would I use clearInterval() here to stop timer when reaches 0?

Here is a simple timer, how would I implement clearInterval() in this bit of code when the timer reaches 0? It currently is infinite. const start = 0.1; //6 seconds let time = start * 60; const count =…
Josh
  • 110
  • 1
  • 7
-1
votes
1 answer

Javascript start and repeat function upon mouseover & stop repeat upon mouseleave

I am successfully starting an animation upon mouseover, but cannot manage to stop it upon mouseleave: Start animation: var executed = false; // to execute only once on repeat hover var startslider = {}; $('#imgBx').mouseover(function(){ if…
-1
votes
1 answer

Angular Service is undefined when trying to implement a timer

I'm trying to accomplish the following: for my web app I tried implementing a timer which automatically resets back to 60s when the user has shown activity (meaning triggered either a click, keydown or scroll event). I used Observables for the Event…
Munchkin
  • 857
  • 5
  • 24
  • 51
-1
votes
2 answers

setInterval continues to run after clearInterval is called

I'm working on a countdown timer for a quiz app I'm building as a homework assignment during bootcamp. Right now everything is functioning properly when rendered except that once the setInterval function inside of startQuiz() hits 0 it's supposed to…
Jon Deavers
  • 139
  • 1
  • 2
  • 14
-1
votes
2 answers

clearInterval Javascript not working, tried two different ways

So I´m trying to stop a countdown when day,hour, minute and seconds are all zero. I tried clearing the interval in two different ways, but they both don´t work. function startInterval (){ const startDate = new Date (); const endDate = new…
thomalex
  • 59
  • 1
  • 2
  • 8
-1
votes
1 answer

How to clear an interval in an if statement

So, I'm working on a game called Mini Arcade which features a bunch of different minigames. I found a way to create a fade effect after I click a button to go to another page. The fade effect seems to work properly, but after going to the console of…
rac0208
  • 39
  • 1
  • 8
-1
votes
1 answer

JavaScript clearInterval does not reset setInterval return ID

clearInterval(intervalNumber) clears the timer but if we call setInterval(fn, interval) again it return new higher ID. Is there way to reset the setInterval return ID where from it started. I tried to search but not found any references. Is this…
Dipak Telangre
  • 1,792
  • 4
  • 19
  • 46
-1
votes
1 answer

Javascript: set Interval of a function in another php file

i have a simple javascript function which runs the meta_data.php file every second. The meta_data.php file contains a simple database query. If the return of that database query is a specific value i want to stop the execution of the meta_data.php…
Dave
  • 3
  • 2
-1
votes
1 answer

How can I get my counter to stop at 0? It decrements to negative numbers

What's wrong with my code? I can't get the timer to stop at 0. It keeps going down to negative numbers. I have my clearInterval set, why isn't the timer stopping? var seconds = 30; $("#timer").on("click", run); $("#timer").on("click", show); var…
Jason
  • 11
  • 3
-1
votes
1 answer

i can't stop setInterval

I have two buttons. The one onClick runs a function that uses a var intId = setInterval{function(), 30} On the second button i try to stop the setInterval with clearInterval(intId) but intId is not global virable and if i put the whole setInterval…
Nick Tsigkros
  • 7
  • 1
  • 1
  • 4
-1
votes
2 answers

Nodejs : clearInterval() using 'this'

I wanted to clearInterval() and I can do so using clearInterval(myInterval) but why can I not using clearInterval(this) ? Here is the code that works : var test = setInterval(function(){ request.post({url: myURL, form: { …
Manpreet Krishan
  • 287
  • 3
  • 11
-1
votes
3 answers

Clear interval inside object method

This code is part of a game where the user has a certain amount of time to input an answer. I want to be able to clear the interval from outside of the object if the user decides to submit an answer before the allotted time has elapsed. I have tried…
-1
votes
1 answer

Why does this setInterval call not work?

Questions: why when change input radio dont work pause? why when change input radio , run function move() before than 2 seconds? This is my code : $(document).ready(function(){ var timer; var which; var number = 0; move(); …
Ehsan
  • 12,655
  • 3
  • 25
  • 44
-1
votes
3 answers

Unable to Clearinterval after set?

I created a slideshow(function slide()): I want this function to start when click on 'play' and pause when click on 'pause'. I used setinterval it works, only clearinterval refuse to work, what am I doing wrong?
proefkip
  • 15
  • 4