JS控制按钮10秒钟后可用的方法
内容摘要
本文实例讲述了JS控制按钮10秒钟后可用的方法。分享给大家供大家参考,具体如下:
<script language="javascript">
function start()
{
document.getElementById("Button1"
<script language="javascript">
function start()
{
document.getElementById("Button1"
文章正文
本文实例讲述了JS控制按钮10秒钟后可用的方法。分享给大家供大家参考,具体如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <script language= "javascript" > function start() { document.getElementById( "Button1" ).disabled = true; document.getElementById( "Button1" ).value = 10; window.setTimeout( "tick()" ,1000); } function tick() { var time = new Number(document.getElementById( "Button1" ).value); if (time>0) { document.getElementById( "Button1" ).value = time-1; window.setTimeout( "tick()" ,1000); } else { document.getElementById( "Button1" ).disabled = false; document.getElementById( "Button1" ).value = "保存" ; } } </script> <form> <INPUT TYPE= "button" NAME= "Button1" id= "Button1" > </form> <script language=javascript> start(); </script> |
希望本文所述对大家JavaScript程序设计有所帮助。
代码注释