<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>数字自减</title>
</head>
<body>
<div id="wait">10</div>
<script>
var wait = document.getElementById("wait");
var interval = setInterval(function () {
var time = --wait.innerHTML;
if(time <= 0){
clearInterval(interval);
}
},1000)
</script>
</body>
</html>
效果是这样的:
GIF.gif











网友评论