1 function showtime() { 2 fun_timedown(5); 3 } 4 function fun_timedown(time) { 5 $("#timedown").val(time + "秒"); 6 time = time - 1; 7 if (time >= 0) { 8 $("#timedown").attr("disabled", "disabled"); 9 setTimeout("fun_timedown(" + time + ")", 1000); 10 11 } else { 12 13 alert(‘倒计时结束啦‘); 14 15 } 16 }
1 <input type="button" id="timedown" value="确定"/> 2 <a href="javascript:showtime()">点击</a>