I\'ve written this simple Carousel. At the moment I\'m using setInterval to run my nextSlide function at certain intervals. I want to defer the timer from running when a user cl
The above code really helped. Thanks Nick. I made a few minor adjustments so that once you clicked the function: the timer would stop, the function would execute, and then the timer initiates and resumes regular intervals.
make sure you re-assign the var int
to the new interval
you create within the click function
.
var int = setInterval(change_slide, 5000);
$("#div").click(function() {
console.log('clicked');
clearInterval(int);
setTimeout(function() {
int = setInterval(change_slide, 5000);
});
});