JQuery實(shí)現(xiàn)倒計時按鈕的實(shí)現(xiàn)代碼
更新時間:2012年03月23日 22:53:23 作者:
頁面中需要實(shí)現(xiàn)某個按鈕點(diǎn)擊完后,禁用它,并顯示倒計時。這個默認(rèn)是3秒,代碼很簡單
復(fù)制代碼 代碼如下:
<head>
<title>test count down button</title>
<script src="http://demo.jb51.net/jslib/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#btn').click(function () {
var count = 3;
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>
有興趣您可以自己實(shí)現(xiàn)一下。
您可能感興趣的文章:
- jquery實(shí)現(xiàn)手機(jī)發(fā)送驗證碼的倒計時代碼
- JQuery實(shí)現(xiàn)倒計時按鈕具體方法
- jquery簡單倒計時實(shí)現(xiàn)方法
- 基于jQuery的倒計時實(shí)現(xiàn)代碼
- jQuery實(shí)現(xiàn)倒計時跳轉(zhuǎn)的例子
- jQuery倒計時代碼(超簡單)
- 利用jQuery實(shí)現(xiàn)漂亮的圓形進(jìn)度條倒計時插件
- jquery 倒計時效果實(shí)現(xiàn)秒殺思路
- jQuery實(shí)現(xiàn)倒計時按鈕功能代碼分享
- jQuery實(shí)現(xiàn)倒計時功能 jQuery實(shí)現(xiàn)計時器功能
相關(guān)文章
JQuery實(shí)現(xiàn)簡單時尚快捷的氣泡提示插件
在程序提交后,為了提高用戶體驗我們需要驗證并提示出錯的位置,利用JQuery我們可以輕松實(shí)現(xiàn)氣泡提示,需要的朋友可以了解下2012-12-12
有關(guān)jQuery中parent()和siblings()的小問題
本文通過一個實(shí)例給大家介紹有關(guān)parent()和siblings()問題原因及解決方案,非常不錯具有參考借鑒價值,感興趣的朋友一起看看吧2016-06-06
jquery mobile changepage的三種傳參方法介紹
本來覺得changePage 那么多option,傳幾個參數(shù)應(yīng)該沒問題結(jié)果翻遍國內(nèi)外網(wǎng)站,基本方法只有三種,下面與大家分享下,感興趣的朋友可以參考下2013-09-09
jquery實(shí)現(xiàn)具有收縮功能的垂直導(dǎo)航菜單
這篇文章主要介紹了jquery實(shí)現(xiàn)具有收縮功能的垂直導(dǎo)航菜單點(diǎn)擊可以展開折疊的導(dǎo)航菜單,感興趣的小伙伴們可以參考一下2016-02-02

