html button 點擊 顯示倒計時秒數
阿新 • • 發佈:2018-07-06
red 計時 ack rip out cli script try 倒計時
如下:
<html> <body> <input type="button" value="click" id="click" onclick="foo(this, 10000);"/> </body> <script> function foo(obj, time) { obj.disabled = true; setTimeout(function() { var x = setInterval(function(){ time= time - 1000; //reduce each second obj.value = (time/1000)%60; if(time==0){ clearInterval(x); obj.value = "retry"; obj.disabled = false; } }, 1000); }, time-10000); } </script> </html>
參考:
html button 點擊 顯示倒計時秒數