3

I'm using the jQuery Countdown plugin (http://keith-wood.name/countdown.html), but I can't seem to reset the timer.

When a button is clicked the folowing function starts the countdown:

function startResetCounter() {
    $('.reset_counter div').countdown({ 
        until: '+3m +0s',
        compact: true,
        format: 'MS',
        onExpiry: resetPage
    });
}

But when I reclick the button it won't reset the timer.

Anyone who can help me out?

4

1 回答 1

5

在startResetCounter函数的顶部添加以下行:

$('.reset_counter div').countdown('destroy'); //remove countdown if it was already used

所以最后你会得到:

function startResetCounter() {
    $('.reset_counter div').countdown('destroy');

    $('.reset_counter div').countdown({ 
       until: '+3m +0s',
       compact: true,
       format: 'MS',
       onExpiry: resetPage
    });
}
于 2012-12-15T15:30:51.450 回答