什麼是這個計時器的問題[JS]有什麼問題在此計時器[JS]
<script type="text/javascript">
var remain = "14:14";
setInterval ("timer()", 660);
function timer(){
var remainM = parseInt(remain.split(":")[0]);
var remainS = parseInt(remain.split(":")[1]);
//document.getElementById("hello").innerHTML = parseInt(remainS);
if (remainS==0) {
if (remainM==0) {
} else {
remainM = parseInt(remainM) - 1;
remainS = 59;
}
} else {
remainS = parseInt(remainS) - 1;
}
var remainSr = String(remainS);
var remainMr = String(remainM);
if (parseInt(remainS)<=9) {remainSr = "0" + String(remainS);}
if (parseInt(remainM)<=9) {remainMr = "0" + String(remainM);}
remain = String(remainMr) + ":" + String(remainSr);
document.getElementById("hello").innerHTML = remain;
}
</script>
從14:09跳到13:59
號()可以避免這些問題。 – cwallenpoole 2011-04-04 20:00:08