Examples
<script><br />
$(function(){<br />
/*仿刷新:检测是否存在cookie*/<br />
if($.cookie("captcha")){<br />
var count = $.cookie("captcha");<br />
var btn = $('#getting');<br />
btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');<br />
var resend = setInterval(function(){<br />
count--;<br />
if (count > 0){<br />
btn.val(count+'秒后可重新获取').attr('disabled',true).css('cursor','not-allowed');<br />
$.cookie("captcha", count, {path: '/', expires: (1/86400)*count});<br />
}else {<br />
clearInterval(resend);<br />
btn.val("获取验证码").removeClass('disabled').removeAttr('disabled style');<br />
}<br />
}, 1000);<br />
}<br />
/*点击改变按钮状态,已经简略掉ajax发送短信验证的代码*/<br />
$('#getting').click(function(){<br />
var btn = $(this);<br />
var count = 60;<br />
var resend = setInterval(function(){<br />
count--;<br />
if (count > 0){<br />
btn.val(count+"秒后可重新获取");<br />
$.cookie("captcha", count, {path: '/', expires: (1/86400)*count});<br />
}else {<br />
clearInterval(resend);<br />
btn.val("获取验证码").removeAttr('disabled style');<br />
}<br />
}, 1000);<br />
btn.attr('disabled',true).css('cursor','not-allowed');<br />
});<br />
});<br />
</script>