JS倒计时执行操作

时间:2023-01-31 07:48:02
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
//换成你的jquery库
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var setTime;
$(document).ready(function(){
var time=parseInt($("#time").text());
setTime=setInterval(function(){
if(time<=0){
clearInterval(setTime);
return;
}
time--;
$("#time").text(time);
},1000);
});
</script>
</head>
<body>
<span id="time">60</span>
</body>
</html>