jquery countdown Timer button settimeout Instance code

Source: Internet
Author: User
This article introduces the jquery countdown timer button SetTimeout example, the need for friends can refer to the copy code code 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); 1s perform one btncount


        });


Btncount = function () {


Start button


if (count = = 0) {


$ (' #btnSubmit '). attr ("Disabled", "");


$ (' #btnSubmit '). Val ("OK");


cleartimeout (timeout); Timeout
set by the settimeout () method can be canceled

            }


else {


count--;


$ (' #btnSubmit '). Val ("Definite (" + 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>


The settimeout preset is executed only once, but we can use recursion to start it ourselves.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.