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
See:
var IntID = setTimer();
function setTimer(){
i = setInterval(startSlider, 4000);
return i;
}
function stopSlider() {
clearInterval(IntID);
}
//Restart Timer
// Option 1 make a restartSlider function and call it
$("#button").click(restartSlider);
function restartSlider(){
IntID = setTimer();
}
//Option 2 create an anonymous function only for that click event.
$("#button").click(function(){
IntID = setTimer();
});