jquery 实现倒计时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 实现倒计时60秒</title>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
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 getCountTime(obj) {
if (countdown == 0) {
obj.attr('disabled', false);
obj.val("免费获取验证码");
countdown = 60;
$('#btn').css('background', '#0af');
return;
} else {
obj.attr('disabled', true);
obj.val("重新发送(" + countdown + ")");
countdown--;
$('#btn').css('background', '#999')
}
setTimeout(function () {
getCountTime(obj)
}, 1000)
}
$('#btn').click(function () {
getCountTime($('#btn'))
})
</script>
</body>
</html>