
JS倒计时代码(可随时点击停止)
发布日期:2021-05-04 09:21:32
浏览次数:35
分类:原创文章
本文共 914 字,大约阅读时间需要 3 分钟。
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><body><input type="button" id="downloadbtn" class="meng1an" οnclick='if(timeout>0) {alert("停止计时");return false;}document.location="https://www.baidu.com/"; this.disabled=true;'><input type="button" id="downloadbtn1" class="meng1an" οnclick='if(timeout>0) {alert("停止计时00");return false;}document.location="https://www.baidu.com/"; this.disabled=true;' value="暂时"><script type="text/javascript">//Js倒计时代码<!--var timeout='100';function countdown(){if (timeout <= 0){document.getElementById("downloadbtn").value = '时间到';if(document.getElementById("downloadfile"))document.getElementById("downloadfile").style.display = '';}if (timeout > 0){document.getElementById("downloadbtn").value = '还有 '+timeout+' 秒';setTimeout('countdown()',1000);}timeout--;}countdown();--></script></body></html>
引用:http://www.jquerycn.cn/a_11291