js图片倒计时
Posted smght
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js图片倒计时相关的知识,希望对你有一定的参考价值。
var discountOnline = !{discountOnline}
if (discountOnline) {
_fresh()
setInterval(_fresh, 1000);
}
var nowtime = false;
function _fresh() {
var endtime = new Date("February 10, 2017 23:59:59");
if(!nowtime){
nowtime = !{dateTime};
}
var leftsecond = parseInt((endtime.getTime() - nowtime) / 1000);
nowtime = nowtime + 1000;
if (leftsecond < 0) {
leftsecond = 0;
}
var _d = parseInt(leftsecond / 3600 / 24);
var _h = parseInt((leftsecond / 3600) % 24);
if (_h < 10) {
_h = "0" + _h;
}
var _m = parseInt((leftsecond / 60) % 60);
if (_m < 10) {
_m = "0" + _m;
}
var _s = parseInt(leftsecond % 60);
if (_s < 10) {
_s = "0" + _s;
}
var _all = _d + " 天 " + _h + " 小时 " + _m + " 分 " + _s + " 秒";
_all = _all.replace(/([0-9]{1})/g, ‘<img width="9" height="16" src="images/time/$1.png">‘)
$(".time").find("span").html(_all);
}
以上是关于js图片倒计时的主要内容,如果未能解决你的问题,请参考以下文章