首页 > 代码库 > 60秒定时减少
60秒定时减少
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div {
width: 200px;
height: 200px;
border: 1px solid black;
margin: 50px auto;
text-align: center;
line-height: 200px;
font-size: 50px;
}
</style>
</head>
<body>
<div id="id"></div>
</body>
<script type="text/javascript">
var id = document.all.id;
var a = 61;
var n = setInterval(function() {
a--;
id.innerHTML = a + "s";
if(a == 0) {
clearInterval(n)
id.innerHTML=(‘时间到了‘)
}
}, 1000);
</script>
</html>
60秒定时减少