jquery 實(shí)現(xiàn)倒計(jì)時(shí)60秒
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
<title>jquery 實(shí)現(xiàn)倒計(jì)時(shí)60秒</title>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<input type="button" id="btn" value="免費(fèi)獲取驗(yàn)證碼" />
<script type="text/javascript">
//發(fā)送驗(yàn)證碼按鈕的60s倒計(jì)時(shí)
var countdown = 60;
$('#btn').css('background', '#0af');
$('#btn').css('border', 'none');
$('#btn').css('borderRadius', '5px');
$('#btn').css('height', '30px');
$('#btn').css('color', '#fff');
$('#btn').css('cursor', 'pointer');
// function sendemail(obj) {
// var obj = $("#btn");
// getCountTime(obj);
// }
function getCountTime(obj) {
if (countdown == 0) {
obj.attr('disabled', false);
obj.val("免費(fèi)獲取驗(yàn)證碼");
countdown = 60;
$('#btn').css('background', '#0af');
return;
} else {
obj.attr('disabled', true);
obj.val("重新發(fā)送(" + countdown + ")");
countdown--;
$('#btn').css('background', '#999')
}
setTimeout(function () {
getCountTime(obj)
}, 1000)
}
$('#btn').click(function () {
getCountTime($('#btn'))
})
</script>
</body>
</html>
文章來源地址http://www.zghlxwxcb.cn/news/detail-757933.html
文章來源:http://www.zghlxwxcb.cn/news/detail-757933.html
到了這里,關(guān)于jquery 實(shí)現(xiàn)倒計(jì)時(shí)60秒的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!