Copy codeThe Code is as follows:
<Head runat = "server">
<Title> </title>
<Script type = "text/javascript" src = "js/jquery-1.3.2.js"> </script>
<Script type = "text/javascript">
Var timeout;
Var count = 10; // bottom 10
$ (Function (){
Timeout = setTimeout (BtnCount, 1000); // execute BtnCount once in 1 s
});
BtnCount = function (){
// Start button
If (count = 0 ){
$ ('# BtnSubmit'). attr ("disabled ","");
$ ('# BtnSubmit'). val ("OK ");
ClearTimeout (timeout); // you can cancel the timeout set by the setTimeout () method.
}
Else {
Count --;
$ ('# BtnSubmit'). val ("OK (" + count. toString () + ");
SetTimeout (BtnCount, 1000 );
}
};
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: Button ID = "btnSubmit" runat = "server" Text = "OK" Enabled = "false"
Onclick = "btnSubmit_Click"/>
</Div>
</Form>
</Body>
SetTimeout is executed only once by default, but we can use recursion to start ourselves.