Handling multiple timers with JavaScript’s setInterval and jQuery Example

Clicking “start multiple intervals” below will start two intervals running that update every 5 seconds. The unique timer ids are the values returned by the setInterval function.

Clicking “clear all intervals” will clear all running intervals.

To clear a specific interval, you need to use that interval’s unique timer id. Clear each interval individually using their corresponding buttons.

The original post explaining in detail is here.




2 Responses to Handling multiple timers with JavaScript’s setInterval and jQuery Example

  1. Pingback: Handling multiple timers with JavaScript’s setInterval and jQuery |

  2. larry says:

    this is a great post, very close to what I am looking for. I want to timers or intervals, but I want the second one delayed and I want them both to end at the same time. so content 1 will change every 10 seconds, content 2 will delay 5 seconds and last for 5 seconds. but I am struggling with the delay and timer

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To include code in your comment: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag(or shortcode) and format it when submitted.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">