2012年(366)
分类: 系统运维
2012-04-14 19:53:28
//引用JQuery
//定时器
var se, m = 0, h = 0, s = 0;
function second() {
if (s > 0 && (s % 60) == 0) { m += 1; s = 0; }
if (m > 0 && (m % 60) == 0) { h += 1; m = 0; }
t = (h <= 9 ? "0" + h : h) + ":" + (m <= 9 ? "0" + m : m) + ":" + (s <= 9 ? "0" + s : s);
document.getElementById("showtime").value = t;
s += 1;
}
$(document).ready(function startclock() { se = setInterval("second()", 1000); });
function pauseclock() { clearInterval(se); }
function stopclock() { clearInterval(se); m = h = s = 0; }
效果如下图: