A jQuery plugin that renders a count-up clock from a defined start time
JavaScript Python Shell
Pull request Compare This branch is 1 commit ahead, 7 commits behind robcowie:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
docs
examples
test
README.textile
jquery.stopwatch.js

README.textile

Simple count-up jQuery plugin

Copyright © 2011 Rob Cowie. Licensed under the MIT license.

Summary

A jQuery plugin that renders a count-up clock from a defined start time. Supports start, stop, toggle, reset, and custom ‘tick’ event.

Usage

  • Initialise and start a default timer
$('').stopwatch().stopwatch('start')

  • Initialise and bind start/stop to click
$('').stopwatch().click(function(){
    $(this).stopwatch('toggle')
})

  • Bind to tick event 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')