<div class="codetitle"> <span><a style="CURSOR: pointer" data="89770" class="copybut" id="copybut89770" onclick="doCopy('code89770')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code89770"> <br><head runat="server"><br> <title></title><br> <script type="text/javascript" src="js/jquery-1.3.2.js"></script><br> <script type="text/javascript"><br> var timeout;<br> var count = 10; // 倒数十下<br> $(function() {<br> timeout = setTimeout(BtnCount, 1000); // 1s执行一次BtnCount<br> });<br> BtnCount = function() {<br> // 启动按钮<br> if (count == 0) {<br> $('#btnSubmit').attr("disabled", "");<br> $('#btnSubmit').val("确定");<br> clearTimeout(timeout); // 可取消由 setTimeout() 方法设置的 timeout<br> }<br> else {<br> count--;<br> $('#btnSubmit').val("确(" count.toString() ")定");<br> setTimeout(BtnCount, 1000);<br> }<br> };<br> </script><br></head><br><body><br> <form id="form1" runat="server"><br> <div><br> <asp:Button ID="btnSubmit" runat="server" Text="确定" Enabled="false"<BR> onclick="btnSubmit_Click"/><br> </div><br> </form><br></body><br> </div> <br>setTimeout预设只执行一次,但我们可以用递归,是它自己启动自己。