Question: 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 clicks on the navigation links for a certain length of time.

Check it out here
<http://jsbin.com/uzixi3/3/edit>

Any feedback on how the rest is written would be good too.

Answer: 
You can save the return value of `setInterval` in a variable to refer to it later - that way you can cancel it if you need to, or restart it.

See [this MDC article](https://developer.mozilla.org/en/window.setInterval) for more details.

The basics are:

```
intervalID = setInterval(flashText, 1000);

//do something...

clearInterval(intervalID);

```
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();
});

```