Simple.Timer

A timer plugin for jQuery

View the Project on GitHub caike/jQuery-Simple-Timer

Usage

Basic example:

<div class="timer" data-seconds-left=1800></div>

<script src="jquery.js"></script>
<script src="jquery.simple.timer.js"></script>
<script>
  $(function(){
    $('.timer').startTimer();
  });
</script>
Would generate the following:


Options

Use the onComplete option for custom behavior on timeout:

$('.timer').startTimer({
  onComplete: function(element){
    element.addClass('is-complete');
  }
});

Use the loop and loopInterval (in seconds) for infinite loop:

$('.timer').startTimer({
  onComplete: function(element){
    element.addClass('is-complete');
  },
  loop: true,
  loopInterval: 3,
});


Tests

QUnit tests can be found in tests/index.html.