javascript - hilios javascript倒计时完成后不会触发回调
问题描述
我在同一页面上有多个倒计时。并且这个脚本是根据单次倒计时修改的。<time>
所以我需要它来触发标签上的每个完成事件的警报。但我不知道为什么它最后没有警觉。请帮帮我。
$('[data-countdown]').each(function() {
var $this = $(this),
finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
var format = '%H:%M:%S';
$(this).html(event.strftime(format));
}).on('finish.countdown', function() {
alert('time up!');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/hilios/jQuery.countdown/2.2.0/dist/jquery.countdown.min.js"></script>
<time data-countdown="2021/07/28 10:28:40"></time>
<br />
<time data-countdown="2021/07/28 12:08:00"></time>
<br />
<time data-countdown="2021/07/29 00:00:00"></time>
解决方案
推荐阅读
- javascript - 将对象数组传播到对象数组反应
- if-statement - 有没有办法让 IF 语句查找偶数或奇数?
- python - 为多个 discord.py 机器人命令设置相同的冷却时间?
- javascript - 如何使用 express、passport 从 cookie 中检索 web-token
- bash - 使用 cURL 编辑要点:“解析 JSON 的问题”,
- docker - Elasticsearch 容器返回格式错误的 http 状态响应
- c# - Blazor:在 Startup.cs 中添加自定义 AuthenticationStateProvider 无法识别
- lightbox2 - 如何更改图片下的文字
- particles - Nvidia Flex 软体约束类型
- javascript - 如何使用另一个数组中其他对象的键替换我的对象数组中的值