计时器

<!DOCTYPE html>
<html>

<head>
<title></title>
<meta http-equiv="content-Type" content="text/html; charset=utf-8 " />
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
</head>

<body>
<div id="showtime"></div>
<form>
<input type="button" value="开始" id="start" onclick="starttime()" />
<input type="button" value="停止" id="end" onclick="endtime()" />
</form>
<script type="text/javascript">
function settime(a) {
if(a <
10) a = "0" + a;
return a;
}
h = 0;
m = 0;
s = 0;

function starttime() {
var showh = s ettime(h);
var showm = s ettime(m);
var shows = s ettime(s);
document.getElementById("showtime").innerHTML = showh + ":" + showm + ":" + shows;
s++;
if(s == 6 0) {
s = 0;
m++;
}
if(m == 6 0) {
m = 0;
h++;
}
t = s etTimeout("starttime()", 1000);
}

function endtime() {
clearTimeout(t);
}
</script>
</body>

</html>
posted @ 2018-08-09 14:47  wyy_wdy  阅读(114)  评论(0编辑  收藏  举报