效果图:

时间可以自己设置

JavaScript使用setInterval实现倒计时操作

JavaScript使用setInterval实现倒计时操作

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="button" value="一分钟倒计时" onclick="daojishi()" />
		<label id="time">60</label>
		<script>
			function daojishi () {
				var time = 60;
				var interval = setInterval(function  () {
					document.getElementById("time").innerHTML=time;
					time-=1;
					if(time==-1){
						clearInterval(interval)
						document.getElementById("time").innerHTML="倒计时结束"
					}
				},1000)
			}
		</script>
		
		 
	</body>
</html>

相关文章:

  • 2021-12-15
  • 2021-10-16
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-09-07
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案