views:

451

answers:

3

the link specified below is a jquery timer plugin.

http://keith-wood.name/countdown.html

Also i use the following to start a timer

$('#timer').countdown({until: 12,compact: true, description: ' to Go'});

My question is how do i deduce that the timer has reached 00:00:00 or the time given has elapsed

Thanks..

+3  A: 

Use a callback. This plugin accepts a variable onExpiry. Pass that in with a reference to the function you want to call when the timer expires.

$('#timer').countdown({until: 12,compact: true, onExpiry:myFunc, description: ' to Go'});
function myFunc() { /* whatever */ }
Plynx
+2  A: 

check the documentation..

onExpiry(function) A callback function that is invoked when the countdown reaches zero. Within the function this refers to the division that holds the widget. No parameters are passed in. Use the expiryText or expiryUrl settings for basic functionality on expiry.

$(selector).countdown({ until: liftoffTime, onExpiry: liftOff}); function liftOff() { alert('We have lift off!'); }

hallie
+1  A: 

the until field specifies when the countdown reaches this point, then, specify onExpiry callback function.

From the JS code

onExpiry: null, // Callback when the countdown expires -
// receives no parameters and 'this' is the containing division

For your function:

$('#timer').countdown({until: 12,compact: true, description: ' to Go', onExpiry = executeMyFunction});

function executeMyFunction() {
   alert("Tada!");
}
The Elite Gentleman
Thanks ...................:) Tada!!!
Hulk
Aha!!! 15 characters minimum is a pain! :-)
The Elite Gentleman