我试图从数据库创建倒数计时器。我已将deltaTimeServer发送给JS。输出是正确的,但他们冻结(不倒计时,我必须按F5)。对我有什么想法?
这是我的代码。
JS
function countDown(){
$(".show").each(function() {
var elm = $(this);
var difTime=this.timestamp;
var day=0,hours=0,minutes=0,seconds=0;
if(difTime>0){
day=Math.floor(difTime/84600);
hours=(Math.floor((difTime/3600))%24) + day*24 ;
minutes=Math.floor(difTime/60)%60;
seconds=Math.floor(difTime)%60;
}
else{
elm.removeClass("show"); //for remove class show
}
elm.html(hours+' H '+minutes+' M '+seconds+' S ');
});
}
function countDown_onLoad(){
$(".show").each(function() {
this.timestamp = pars