jQuery Countdown插件 - 仅显示非零时段 [英] jQuery Countdown Plugin - only show non-zero periods

查看:177
本文介绍了jQuery Countdown插件 - 仅显示非零时段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery倒计时插件对倒计时进行编码。

I'm coding a countdown with jQuery countdown plugin.

我只希望它显示有效('非零')期间,例如而不是

I only want it to show active ('non-zero') periods, e.g. instead of

剩余时间:0天,0小时,13分钟,20秒

它应该只显示

13分钟,20秒。

我的代码是:

$('#countdown').countdown({
    expiryUrl:'index.php?show=main', 
    expiryText: 'EXPIRED', 
    until: timeleft, 
    layout:'{d<}{dn} {dl} and {d>}{h<}{hn} {hl}, {h>}{m<}{mnn} {ml}, {m>}{s<}{snn}{sl}{s>}'
});

但问题是这个代码隐藏了'Days'期间,但不是'Hours' /分钟'

But the problem is that with this code it hides the 'Days' period, but NOT the 'Hours/Minutes'

所以目前我得到这个:

剩余时间:0小时,10分钟,27秒

我需要做些什么才能隐藏所有零期?

What do I have to do to hide ALL zero periods?

谢谢你好!

推荐答案

Hiya请看这里添加2 jsfiddle以显示差异: http://jsfiddle.net/8JJ9B/6/ (只有秒数会出现注意当您设置时会发生这种情况 **格式** 倒计时选项为小写) http://jsfiddle.net/8JJ9B/4/ (零也会出现,因为我将格式选项设置为大写字符)更新 http:// jsfiddl e.net/cUW4M/

Hiya please see here adding 2 jsfiddle to show you the difference: http://jsfiddle.net/8JJ9B/6/ (Only the seconds will appear note this happens when you set **format** option of countdown as lower case) and http://jsfiddle.net/8JJ9B/4/ (Zero will appear as well because I have format option set as Capital characters) update http://jsfiddle.net/cUW4M/

为了避免出现任何非零值,倒计时插件有一个名为格式的引用:选项作为小写字符

To avoid any non-zero value to appear countdown plugin has a reference called format: with options as lower case character

进一步 http://keith-wood.name/countdownRef.html#format


[quote] 格式选项== ...使用大写字符表示必填时段,或
对应下限 - 可选句点的大小写字符,即如果非零则仅显示
。一旦显示一个可选期间,之后所有的
也会显示... [Unquote]

[Quote]Format option == ...Use upper-case characters for mandatory periods, or the corresponding lower-case characters for optional periods, i.e. only display if non-zero. Once one optional period is shown, all the ones after that are also shown...[Unquote]

代码

$('#highlightCountdown').countdown({until: 0, format: 'hmS',onTick: highlightLast5});

这篇关于jQuery Countdown插件 - 仅显示非零时段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆