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

Javascript - JQuery - clearInterval/setInterval - iframe cycle won't stop on click

I'm fairly new to Javascript in general, and I cobbled together a small script from things found mostly on this site to try to get a small iframe to cycle through a bunch of links, which it does brilliantly. However, I also want it to stop cycling…
Sarah Carter
  • 86
  • 2
  • 3
0
votes
2 answers

Javascript/jQuery can't seem to get ClearInterval to work

I am reading a jQuery book and trying to do an example. In the example lightning flashes on the screen, and that part works fine. The problem is that when you switch tabs, and then switch back, the lightning starts flashing in rapid succession. The…
Benjamin Thvedt
  • 351
  • 1
  • 3
  • 17
-1
votes
3 answers

JavaScript setInterval and clearInterval not working

I am trying to use setInterval and clearInterval in literally the simplest case possible: var passiveInterval = ""; var activeInterval = ""; function myStartFunction() { ... passiveInterval = window.setInterval(passiveCheck, pIntAmt); …
Maxwell Collard
  • 2,587
  • 3
  • 16
  • 12
-1
votes
2 answers

How to start the timer from 0 on page refresh in react app

I've a setInterval timer in useEffect and I want the timer to start from zero on page refresh. But it's not. const [timer, setTimer] = useState(0) useEffect(() => { const timer = setInterval(() => { const d = new Date(), seconds =…
-1
votes
3 answers

javascript window.open not following setInterval parameters?

I have a very oddly specific project which requires a number of photos to be opened in multiple window popups. (I understand the usability of this, please bypass that for the moment.) I am running the following script on body load, which works…
RodeoRamsey
  • 498
  • 2
  • 8
  • 20
-1
votes
2 answers

Counter with clearInterval, not restarting after button click

There is a word-translation card page which includes: A 3-second countdown that runs immediately after the page loads and when you move to a new word after press the 'Correct' button. Word and his translate which appears after 'Excellent' button…
CarloDiPalma
  • 63
  • 2
  • 10
-1
votes
3 answers

clearInterval on 'mouseleave'

I'm creating a visual counter in my html using Javascript. At first the counter is '0'. On mouseenter it starts counting till 10 (adding +1 every second), and on moueseleave it should reset to 0 again and stop counting, however, when I move the…
Zixxy7
  • 71
  • 4
-1
votes
1 answer

SetInterval, clearInterval - How to display image for set time then make it disappear

I am trying to add a feature to my game where an img appears after a set amount of time. The is only displayed for a set time before it disappears again or until it is clicked. Here is my code below but it doesn't work because the clearInterval is…
Owen
  • 13
  • 4
-1
votes
1 answer

clearInterval() function is not working in JavaScript

i tried to add a simple random number generater upto 10. When code is excecuted its working fine and generating random numbers. after that i added a condition that when function generate 5 random number function should stop working, So I added…
Somraj
  • 23
  • 6
-1
votes
1 answer

clearInterval not removing the setInterval function

I am trying to create a setInterval function that checks to see whether an element exists after a click event. The setInterval works fine but I cant get it to clear when using clearInterval. So what I am trying to achieve is that once the element…
user16732475
  • 15
  • 1
  • 6
-1
votes
3 answers

clearInterval does not seem to be working

I'm trying to make a simple javascript counter. Basically, I'm getting an integer value from a user by input and I want to count descending from that value to 0. So I coded this: let inputCounter = document.querySelector("#input-counter"); let…
Pouya
  • 114
  • 1
  • 8
  • 36
-1
votes
2 answers

How to make clearInterval() work in JavaScript

I want to make an element (id=runner) move across the page by n pixels after a mouseover event, then stop at a certain position (left = 2000px), using setInterval() to repeatedly call move_left(), then clearInterval() when left == 200px. I can make…
ridonky
  • 13
  • 1
-1
votes
1 answer

ClearInterval doesn't work, the following setInterval restart with 2x speed

I have a simple slideShow on witch i want a "pause" and "play" function, with onClick, using setInterval and clearInterval. The first setInterval works good. The following clearInterval create a pause in the loop, but don't reset intervalId, so, the…
-1
votes
1 answer

clearInterval isn'tworking

I have to clear the interval but I don't know why it isn't working. Normally it schould be quite simple, but I just can't find out whats wrong. if(data.groupStandings[0].active === true){ Tabelle(); var timerId = setInterval(countdown, 1000); …
-1
votes
1 answer

Why can't I switch between my "stop" and "start" buttons?

I'm making a stopwatch, and my codes is supposed to make the "start" button turn to "stop" button whenever I click on the "start" button and the opposite. My start button seems to work but when I try to switch it to "stop" it doesn't work. I don't…
Ashley
  • 73
  • 6