A jQuery plugin that renders a count-up clock from a defined start time. Supports start, stop, toggle, reset, and custom 'tick' event.
- Initialise and start a default timer
$('').stopwatch().stopwatch('start')- Initialise and bind start/stop to click
$('').stopwatch().click(function(){
$(this).stopwatch('toggle')
})- Bind to
tickevent and reset when 10 seconds has elapsed
$('').stopwatch().bind('tick.stopwatch', function(e, elapsed){
if (elapsed >= 10000) {
$(this).stopwatch('reset');
}
}).stopwatch('start')- Start at non-zero elapsed time
$('').stopwatch({startTime: 10000000}).stopwatch('start')Provided by the jintervals lib. If you don't
include this library, the default output format HH:MM:SS is used.
Pass a format pattern as the format option. jsintervals provides a rich syntax for formatting
time intervals, perhaps best illustrated by some examples.
'{MM}:{ss}' --> 01:05
'{MMM}:{ss}' --> 001:05
'{M}m, {s}s' --> 1m, 5s
'{Minutes} and {seconds}' --> 1 minute and 5 seconds
'{Greatest} ago' --> 1 minute agoThe full documentation of the syntax is at http://code.google.com/p/jintervals/wiki/Documentation.
A formatter function can be supplied as formatter in options. It receives milliseconds and
options and must return a string.
Copyright (c) 2012 Rob Cowie. Licensed under the MIT license.