Home > Article > Web Front-end > Button countdown effect implemented by JQuery_jquery
The example in this article describes the button countdown effect implemented by JQuery. Share it with everyone for your reference, the details are as follows:
An effect that displays a countdown on the button and automatically sets the button to unavailable when the countdown is completed. The specific code is as follows:
<html> <head> <title>test count down button</title> <script src="jquery1.8.3.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $('#btn').click(function () { var count = 10; var countdown = setInterval(CountDown, 1000); function CountDown() { $("#btn").attr("disabled", true); $("#btn").val("Please wait " + count + " seconds!"); if (count == 0) { $("#btn").val("Submit").removeAttr("disabled"); clearInterval(countdown); } count--; } }) }); </script> </head> <body> <input type="button" id="btn" value="Submit" /> </body> </html>
The screenshot of the running effect is as follows:
I hope this article will be helpful to everyone in jQuery programming.