[英]My stoper doesn't start
In my code after click 'start ' I would like to see counting. 单击“开始”后,在我的代码中,我希望看到计数。
var h = 0; var m = 0; var s = 0; function stoper() { s++; if (s == 60) { s = 0; m++; if (m == 60) { m = 0; h++; } } refresh(); } function refresh() { czas = h + ":" + m + ":" + s document.getElementById("czas").innerHTML = czas; }
<div id="czas"> <button onclick="setInterval(refresh,1000)">Start</button> </div>
您应该致电stoper
而不refresh
:像这样:
<button onclick="setInterval(stoper,1000)">Start</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.