标签:
倒计时效果:
javascript:
var seconds; var timer=null; function setLeftTime() {
clearInterval(timer); seconds = parseInt($("#hid").val(), 10); timer = setInterval(showSeconds,1000); } function showSeconds() { var day1 = Math.floor(seconds / (60 * 60 * 24)); var hour = Math.floor((seconds - day1 * 24 * 60 * 60) / 3600); var minute = Math.floor((seconds - day1 * 24 * 60 * 60 - hour * 3600) / 60); var second = Math.floor(seconds - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60); if (day1 < 0) { clearInterval(timer); $("#loan_time").html("已经结束!"); } else { $("#loan_time").html(day1 + " 天 " + hour + " 小时 " + minute + " 分 " + second + " 秒"); } seconds--; }
setLeftTime();
标签:
原文地址:http://www.cnblogs.com/wayofeng/p/5627876.html