html button 点击 显示倒计时秒数


如下:

 

<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>

 

 

参考: 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM