<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Document</title>
<script src= ' jquery-1.7.js ' ></script>
<body>
<input type= "button" value= "Search" class= "but" >
</body>
<script>
$ (function () {
$ (document). Delegate ('. But ', ' click ', function () {
var _this = $ ('. but ')
var count = 2; @1, define a number of seconds
var Keng = setinterval (kengno,1000); @2, write a function function that has a method executed every second.
function Kengno () {
_this.attr ("Disabled", true). val ("Please search" after "+count+"); @3, disable button after click, modify value
$ ('. but ');
if (count = = 0) {//@4, when 5 seconds to complete the judgment
_this.val ("Search"). Removeattr ("Disabled"); @5, clear disable attribute, reset value
Clearinterval (Keng); @6, clearing functions
}
count--;//@ each execution of this method will be reduced by 1
}
})
})
</script>
Jquery Timer Countdown