jQuery倒计时完成回调 [英] Jquery Countdown on finish Callback
问题描述
此插件将显示实时倒计时,并将显示在网页上.
This plugin will show real time countdown which will show on the webpage.
我在官方网站上阅读了有关完成回调的文档.
我想做的是,如果计时器完成计数,它将隐藏 span#limit.
What I try to do is that if the timer finish counting, it will hide span#limit.
这是链接:
http://hilios.github.io/jQuery.countdown/documentation.html
这是我的代码:
HTML:
<span id="limit">
<input type="hidden" name="limit" value="<?php echo $dataproduct['limit']; ?>" />
</span>
jQuery:
var data = $("input[name=limit]").val();
$("#limit").countdown(data, function(event) {
$(this).text(event.strftime('%D days %H:%M:%S'));
.on('finish.countdown', function() {
$(this).hide();
)};
});
它将在网页上显示倒计时:
it will show countdown like this on the webpage :
01天19:40:00
直到
00天00:00:00
问题是这个跨度没有隐藏,就像我尝试做的那样.
The problem was this span did not hide just like I try to do.
我的代码有什么问题?打回来?语法错误?
What's wrong with my code? Callback? Wrong syntax?
推荐答案
尝试以下操作:根据您提供的文件,您需要在.countdown()
函数的括号内关闭后调用.on('finish.countdown'
.您的代码将按预期工作.
Try this : As per doucument you have provide, you need to call .on('finish.countdown'
after closing bracket of .countdown()
function. And your code will work as expected.
var data = $("input[name=limit]").val();
$("#limit").countdown("2015-07-02 19:40:00", function(event)
{
$(this).text(event.strftime('%D days %H:%M:%S'));
}).on('finish.countdown', function() {
$(this).hide();
});
JSFiddle Demo
注意:请根据您的方便更改日期输入,以便您可以看到倒计时在短时间内变为零.
NOTE: Please change the date input as per your convinient so that you can see countdown to become zero in short time.
这篇关于jQuery倒计时完成回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!