Answer the question
In order to leave comments, you need to log in
Why is clearInterval not working?
I created a simple slider https://jsfiddle.net/serii/otoj13zn/1/
By clicking on the picture, setInterval is launched, and the active class is set to the parent.
If I click again, the active class is removed, and setInterval should clear and the sliders should end.
But clearInterval doesn't work.
Does anyone have time to take a look?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
It is necessary to split the loopSlider into two different functions:
1. Switching the state on click (toggle)
2. Timer function with a global timer identifier (animation / animation frame function)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question