这个js倒计时,在IE里显示NaN天 NaN时 NaN分 NaN秒 ,是哪里不兼容呢,要怎么改 5
varsetday=$(this).text();varcountd=$(this);varsetday=Date.parse(setday)*1;varcount,d,...
var setday = $(this).text();
var countd =$(this);
var setday = Date.parse(setday)*1;
var count,d,h,m,s;
var countdown = setInterval(function() {
var today = new Date();
today = today.getTime();
today = today*1;
alert();
count = setday - today;
count = count/1000;
count = Math.floor(count);
d = Math.floor(count/86400);
h = Math.floor((count%86400)/3600);
m = Math.floor(((count%86400)%3600)/60);
s = Math.floor(((count%86400)%3600)%60);
var msgtime =d + "天 " + h + "时 " + m + "分 " + s + "秒 ";
$(countd).text(msgtime);
},1000); 展开
var countd =$(this);
var setday = Date.parse(setday)*1;
var count,d,h,m,s;
var countdown = setInterval(function() {
var today = new Date();
today = today.getTime();
today = today*1;
alert();
count = setday - today;
count = count/1000;
count = Math.floor(count);
d = Math.floor(count/86400);
h = Math.floor((count%86400)/3600);
m = Math.floor(((count%86400)%3600)/60);
s = Math.floor(((count%86400)%3600)%60);
var msgtime =d + "天 " + h + "时 " + m + "分 " + s + "秒 ";
$(countd).text(msgtime);
},1000); 展开
2个回答
展开全部
count = setday - today;试一下改成
count = parseFloat(setday) - parseFloat(today);
如果还有问题,可以试一下,在count = setday - today;加上一句alert(setday+";"+today);定位一下是不是这两个变量出了问题
count = parseFloat(setday) - parseFloat(today);
如果还有问题,可以试一下,在count = setday - today;加上一句alert(setday+";"+today);定位一下是不是这两个变量出了问题
更多追问追答
追问
不行,好像是这里出问题了var setday = Date.parse(setday)*1; ,这里就是NaN了,
追答
setday初始值是什么?
展开全部
var d=new Date("07-06-2013 10:40:20");
var tody=new Date();
var day=parseFloat(tody.getDate()-d.getDate());
var hour=parseFloat(tody.getHours()-d.getHours());
var min=parseFloat(tody.getMinutes()-d.getMinutes());
var miao=parseFloat(tody.getSeconds()-d.getSeconds());
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询