首页 > 解决方案 > 如何检测 Harshen 的 jQuery-countdownTimer 何时达到 00:00

问题描述

我正在集成Harshen Panday 的 countdownTimer 插件,但我想hello在它到达时打印00:00。有什么方法可以让我收到该事件的通知?

$(function() {
  $('#ms_timer').countdowntimer({
    minutes: 03,
    seconds: 00,
    size: "lg"
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://harshen.github.io/jquery-countdownTimer/jquery.countdownTimer.min.js"></script>

<span id="ms_timer" class="d-block mb-2"></span>
<h3 id="getTime" class="mb-3 text-uppercase"><b>Book Consultation</b></h3>
<h5 id="getPrice"><b class="strike">RS. 500</b></h5>
<h2 class="mb-0"><b>RS. 300</b></h2>

标签: javascripthtmljquery

解决方案


该文档给出了timeUp

时间到

  • 类型:Function
  • 默认:null
  • 倒计时归零时调用的回调函数的名称。函数内this是指保存小部件的分区。不传入任何参数。为此选项提供名称,不带引号。

$(function() {
  $('#ms_timer').countdowntimer({
    minutes: 00,
    seconds: 05,
    size: "lg",
    timeUp: () => console.log("Hello")
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://harshen.github.io/jquery-countdownTimer/jquery.countdownTimer.min.js"></script>
<span id="ms_timer" class="d-block mb-2"></span>
<h3 id="getTime" class="mb-3 text-uppercase"><b>Book Consultation</b></h3>
<h5 id="getPrice"><b class="strike">RS. 500</b></h5>
<h2 class="mb-0"><b>RS. 300</b></h2>


推荐阅读