用图片展示倒计时 countDown: function(){ var timer = null, nextH = 0, //初始小时 nextM = 0, //初始分钟 nextS = 3, //初始秒 hPrev = hAfter = mPrev = mAfter = sPrev = sAfter = 0; var hour = splitUnitDecade(nextH); var minute
countDown: function(){ var timer = null, nextH = 0, //初始小时 nextM = 0, //初始分钟 nextS = 3, //初始秒 hPrev = hAfter = mPrev = mAfter = sPrev = sAfter = 0; var hour = splitUnitDecade(nextH); var minute = splitUnitDecade(nextM); var second = splitUnitDecade(nextS); $(".hour-prev")[0].src = commonImgUrl + "0"+hour[0]+".png"; $(".hour-after")[0].src = commonImgUrl + "0"+hour[1]+".png"; $(".minute-prev")[0].src = commonImgUrl + "0"+minute[0]+".png"; $(".minute-after")[0].src = commonImgUrl + "0"+minute[1]+".png"; $(".second-prev")[0].src = commonImgUrl + "0"+second[0]+".png"; $(".second-after")[0].src = commonImgUrl + "0"+second[1]+".png"; //个位和十位 function splitUnitDecade(num){ var numArr = []; unitNum = num % 10, decateNum = parseInt(num / 10); numArr.push(decateNum); numArr.push(unitNum); return numArr; } if(nextH==0 && nextM==0 && nextS==0){ clearInterval(timer); }else{ timer = setInterval(function(){ if(nextS == 0){ if(nextM == 0){ if(nextH == 0){ clearInterval(timer); }else{ nextH--; var hour = splitUnitDecade(nextH); $(".hour-prev")[0].src = commonImgUrl + "0"+hour[0]+".png"; $(".hour-after")[0].src = commonImgUrl + "0"+hour[1]+".png"; nextM = 59; $(".minute-prev")[0].src = commonImgUrl + "05.png"; $(".minute-afterr")[0].src = commonImgUrl + "09.png"; } }else{ nextM--; var minute = splitUnitDecade(nextM); $(".minute-prev")[0].src = commonImgUrl + "0"+minute[0]+".png"; $(".minute-after")[0].src = commonImgUrl + "0"+minute[1]+".png"; nextS = 59; $(".second-prev")[0].src = commonImgUrl + "05.png"; $(".second-after")[0].src = commonImgUrl + "09.png"; } }else{ nextS--; var second = splitUnitDecade(nextS); $(".second-prev")[0].src = commonImgUrl + "0"+second[0]+".png"; $(".second-after")[0].src = commonImgUrl + "0"+second[1]+".png"; } },1000) } }