<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>倒计时</title>
<style>
body{font-family: "微软雅黑";}
h1,p{margin: 10px auto;width: 100%;text-align: center;}
p{font-size: 50px;font-weight: bold;}
i{font-style: normal;};
</style>
</head>
<body>
<h1>神圣的倒计时</h1>
<p>
<span id="minute">2</span>:<i id="second">5</i>
</p>
<script type="text/javascript">
var sec=document.getElementById("second");
var min=document.getElementById("minute");
var s=5;
var m=2;
function timer(){
s--;
sec.innerHTML=s;
if (s==0) {
m--;
min.innerHTML=m;
if (m==0&&s==0){
min.innerHTML=0;
sec.innerHTML=0;
// // clearInterval(i);
alert("8哥打一圈");
}
s=5;
sec.innerHTML=s;
}
}
var i=setInterval(timer,1000);
</script>
</body>
</html>
问题:
1、为何我 if (m==0&&s==0)会在1:1的时候出现弹窗而不是0:0,但是我将0改为-1即可实现0:0的时候出现弹窗
2、倒计时如何改为60:32---00:05--00:00这样的格式?代码该如何实现?
stone310
慕的地6079101
wubin_work