Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 文本消息倒计时并在到期时更改样式_Jquery_Css_Jquery Countdown - Fatal编程技术网

Jquery 文本消息倒计时并在到期时更改样式

Jquery 文本消息倒计时并在到期时更改样式,jquery,css,jquery-countdown,Jquery,Css,Jquery Countdown,嗨,我有下面的柜台: 但我真的想在它达到零时显示一条消息,在作者网站(callback选项卡下的keith-wood.name/countdown.html)上,它说这应该是代码: $('#expireMessage').countdown({until: shortly, expiryText: '<div class="over">It\'s all over</div>'}); $('#expireMessageStart').click(funct

嗨,我有下面的柜台:

但我真的想在它达到零时显示一条消息,在作者网站(callback选项卡下的keith-wood.name/countdown.html)上,它说这应该是代码:

$('#expireMessage').countdown({until: shortly, 
    expiryText: '<div class="over">It\'s all over</div>'}); 

$('#expireMessageStart').click(function() { 
    shortly = new Date(); 
    shortly.setSeconds(shortly.getSeconds() + 5.5); 
    $('#expireMessage').countdown('option', {until: shortly}); 
});
$('#expireMessage')。倒计时({直到:很快,
expiryText:“一切都结束了”});
$('#expireMessageStart')。单击(函数(){
短=新日期();
shorty.setSeconds(shorty.getSeconds()+5.5);
$(“#expireMessage”).countdown('option',{until:short});
});
我试了几个小时,但没能成功:(

我不想要开始按钮,只要在计时器过期时用文本填充框,然后应用其他样式(#defaultCountdownExpired)

我希望有人能帮助我

事先非常感谢

更新:

user3003216给了我以下代码:

$(function () {
$('#defaultCountdown').countdown({until: +5,
                                  onExpiry: function() {
                                      $('#defaultCountdown').css("background-color","red");
                                      $('#defaultCountdown').html('<div class="over">It\'s all over</div>');
                                  },});
});
$(函数(){
$('#defaultCountdown')。倒计时({until:+5,
onExpiry:function(){
$('#defaultCountdown').css(“背景色”,“红色”);
$('#defaultCountdown').html(“一切都结束了”);
},});
});
这样做可以应用样式,文本也会更改,但当页面加载/重新加载过期的计时器时,它会再次显示0

因此,只有当计时器过期时页面打开时,它才起作用:(

下面是一个新的例子:


谢谢。

如果日期已经过期,为什么还要初始化CountdDown?如果我不需要它,我不会要求它。只是在我看来,你可以根据目标日期检查页面加载的日期。如果日期较短,只需设置html,否则初始化timeroke,我怎么做?你能举个例子吗?
如果(dateNow