Jobert Enamno
Jobert Enamno

Reputation: 4461

Restart Countdown Timer when expired

I'm using countdown timer from here http://keith-wood.name/countdown.html

I want if my timer is expired it will restart. My implementation below did not restart the timer after expiration. Please help.

HTML

  <span id="divtimerholder"></span>

JavaScript

 $(document).ready(function() {
          startCountdown();
        function startCountdown() {
            $('#divtimerholder').countdown({ layout: '{mnn} : {snn}', timeSeparator: ':', until: 60, onExpiry: restartCountdown
            });

        }
        function restartCountdown() {
            $('#divtimerholder').destroy();
            startCountdown();
        }
    });

JSFiddle http://jsfiddle.net/zD2M2/

Upvotes: 1

Views: 4718

Answers (3)

vidya
vidya

Reputation: 69

$('#divtimerholder').countdown('option', {until: 3});

works like a charm. thanks for the answer LeGEC

Upvotes: 1

LeGEC
LeGEC

Reputation: 51850

Set the option :

$('#divtimerholder').countdown('option', {until: 3});

http://jsfiddle.net/zD2M2/1/

Upvotes: 7

Impirator
Impirator

Reputation: 1442

Looks like the code to unmake a countdown timer should be:

$("#divtimerholder").countdown('destroy');

Upvotes: 1

Related Questions