不重置的jQuery倒计时
您好我正在使用Keith Wood的jQuery倒计时( http://keith-wood.name ),我想知道当有人刷新页面时我是如何保持计数器的。 因此,每当有人进入页面时,他必须看到倒计时
我是jQuery的新手。 我使用了jquery.countdown.min.js文件。
这是JS小提琴http://jsfiddle.net/wthf9/2/
jQuery(document).ready(function($){ jQuery('#offline-countdown').countdown({ until:'+1d, 1h, 3h, 3m, 1s', format: 'DHMS', labels: ['Years','Months','Weeks','Days','Hours','Minutes','Seconds'] }); });
非常感谢有人可以帮助我!
UPDATE!
如果有人需要,你可以在这里找到答案:
http://jsfiddle.net/wthf9/7/
这将确保倒计时在页面刷新期间“持续”。
这种方式不使用cookie或本地存储的原因是因为时间是固定的,所以当刷新页面时,动态计算新的时间给出状态的外观。
$(function(){ var newYear = new Date(); newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1); $('#offline-countdown').countdown({until: newYear}); });
这是一个实际的例子。 (尝试用这个小提琴刷新页面)
旁注: $(function() { });
与$(document).ready(function() { });