Create a simple countdown object


/**
 * Create and process a new Countdown object.
 * 
 * @param seconds
 *  Integer
 */
function Countdown(seconds) {
	
	$('#timer').html(seconds);
	
	var timer = window.setInterval(function() {
	  if (seconds === 0) {
        clearInterval(timer);
        return;
	  }
      seconds -= 1;
      $('#timer').html(seconds);
	}, 1000);
	
	this.stop = function() {
      clearInterval(timer);
	}
	
}

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.