JQuery Timer

http://jchavannes.com/jquery-timer/demo https://github.com/jchavannes/jquery-timer

HTML

<script src="http://jchavannes.com/include/scripts/timer-demo.js"></script>
<script src="http://jchavannes.com/include/scripts/3p/jquery.timer.js"></script>
    <h1>jQuery Timer Demo</h1>
    <p>Project home: <a href="http://jchavannes.com/jquery-timer" target="_blank">http://jchavannes.com/jquery-timer</a></p>
    <p><a href="res/demo.js" target="_blank">View Source</a></p>

    <hr/><h3 style='margin-top:20px;'>Example 1 - Stopwatch (counts ups)</h3>
    <span id="stopwatch">60:00</span>
    <p>
        <input type='button' value='Play/Pause' onclick='Example1.Timer.toggle();' />
        <input type='button' value='Stop/Reset' onclick='Example1.resetStopwatch();' />
    </p>
    <br/>
    <br/>

    <h3>Example 2 - Countdown Timer</h3>
    <span id="countdown">05:00:00</span>
    <form id="example2form">
        <input type='button' value='Play/Pause' onclick='Example2.Timer.toggle();' />
        <input type='button' value='Stop/Reset' onclick='Example2.resetCountdown();' />
        <input type='text' name='startTime' value='300' style='width:30px;' />
    </form>

    <h3>Example 3 - Slideshow (preserves time remaining when paused)</h3>
    <div class="galleryImages">
        <img src='res/img/1.jpg' alt='' />
        <img src='res/img/2.jpg' alt='' />
        <img src='res/img/3.jpg' alt='' />
        <img src='res/img/4.jpg' alt='' />
        <img src='res/img/5.jpg' alt='' />
        <img src='res/img/6.jpg' alt='' />
        <img src='res/img/7.jpg' alt='' />
        <img src='res/img/8.jpg' alt='' />
        <img src='res/img/9.jpg' alt='' />
        <img src='res/img/10.jpg' alt='' />
        <img src='res/img/11.jpg' alt='' />
        <img src='res/img/12.jpg' alt='' />
        <img src='res/img/13.jpg' alt='' />
        <img src='res/img/14.jpg' alt='' />
        <img src='res/img/15.jpg' alt='' />
        <img src='res/img/16.jpg' alt='' />
        <img src='res/img/17.jpg' alt='' />
    </div><br/>
    <div id="timeRemaining"><br/></div>
    <p...

JavaScript

var count = 0;
var timer = $.timer(function() {
    $('#counter').html(++count);
});
timer.set({ time : 1000, autostart : true });