【问题标题】:jQuery Countdown plugin restartjQuery Countdown 插件重启
【发布时间】:2012-09-26 13:16:49
【问题描述】:

我正在使用 jQuery Countdown 插件 (http://keith-wood.name/countdown.html),但我似乎无法重置计时器。

当一个按钮被点击时,下面的函数开始倒计时:

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

但是当我重新单击按钮时,它不会重置计时器。

谁能帮帮我?

【问题讨论】:

    标签: jquery plugins timer countdown


    【解决方案1】:

    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
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多