Category Archives: JavaScript

Handling multiple timers with JavaScript’s setInterval and jQuery

· 4 Comments · in JavaScript, jQuery

For a recent project I needed to create a slideshow with auto play capability. To achieve this I used JavaScript’s setInterval to rotate the slides every 15 seconds.

intervalId = window.setInterval("moveSlide()",15000);

To stop animation the timer needed to be cleared. The conventional way is:

window.clearInterval(intervalId);

All well and good if you only have one timer on a page.
(more…)