var hour = 0;//小时
var minute = 0;//分钟
var second = 0;//秒
function HMSTimer() {
second++;
if(second >= 60) {second = 0; minute++;}
if(minute >= 60) {minute = 0; hour++;}
if(hour >= 24) {hour = 0;}
var hour_1 = hour < 10 ? ("0" + hour) : hour;
var minute_1 = minute < 10 ? ("0" + minute) : minute;
var second_1 = second < 10 ? ("0" + second) : second;
$(".timer-item-hour").text(hour_1);
$(".timer-item-min").text(minute_1);
$(".timer-item-second").text(second_1);
}
setInterval(HMSTimer, 1000);
效果图:
制作计时器成功后
网友评论