为了账号安全,请及时绑定邮箱和手机立即绑定

setTimeout()只执行一次,然后就不跳动了

setTimeout()只执行一次,然后就不跳动了

Godco 2016-07-11 01:06:17
function countDown($class){    var t = $($class).attr("endTime");    var targetTime = new Date(t);    targetTime = targetTime.getTime();    var nowTime = new Date();    nowTime = nowTime.getTime();    reflash($class,targetTime,nowTime);}function reflash(_class,targetTime,nowTime){    var _second = 1000;    var _minute = _second * 60;    var _hour = _minute * 60;    var _day = _hour * 24;    var difference = targetTime - nowTime;    var days = Math.floor(difference / _day);    var hours = Math.floor((difference % _day) / _hour);    var minutes = Math.floor((difference % _hour) / _minute);    var second = Math.floor((difference % _minute)/_second);    var lastTime = "<i></i>剩余"+days+"天"+nol(hours)+"时"+nol(minutes)+"分"+nol(second)+"秒";    $(_class).html(lastTime);       var t = setTimeout(function(){        reflash(_class,targetTime,nowTime)    },1000);}countDown($(".residual_time"))
查看完整描述

1 回答

?
柠檬酸钠

TA贡献331条经验 获得超534个赞

把setTimeout换成setInterval试一试

查看完整回答
1 反对 回复 2016-07-11
  • 1 回答
  • 1 关注
  • 2116 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信