yyzhu 2011-08-15
function fresh(t) { var RemainTime = t.val(); var endtimeStr = RemainTime.replace(/-/g,"/"); var endtime=new Date(endtimeStr); var nowtime = new Date(); var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000); d=parseInt(leftsecond/3600/24); h=parseInt((leftsecond/3600)%24); m=parseInt((leftsecond/60)%60); s=parseInt(leftsecond%60); t.parents(".joinTo").find("[myname=lastTime]").html("剩余时间:<b>"+d+"</b> 天 <b>"+h+"</b> 时 <b>"+m+"</b> 分 <b>"+s+"</b> 秒 "); if(leftsecond<=0){ t.parents(".joinTo").find("[myname=lastTime]").html("<b>抢购已结束</b>"); clearInterval(sh); } } var sh; sh=setInterval(function(){ $("input[name=time]").each(function() { fresh($(this)); }); },1000);