jq代码
$(".code").on("click", function() {
var s = parseInt($(".code b").html());
var phone = $("#phone").val();
if (s > 0) {
layer.msg("请等待" + s + "秒重发")
return false;
}
$.post("{:U('code')}", {
phone: phone
}, function(e) {
if (e.status == 1) {
$(".code").html("等待<b>60</b>秒");
var ping = window.setInterval(function() {
var s = parseInt($(".code b").html());
if (s == 0) {
$(".code").html("重发验证码")
clearInterval(ping);
return false;
} else {
$(".code b").html(s - 1);
}
}, 1000);
} else {
layer.msg(e.info);
}
});
return false;
})html代码 <em class="code">获取验证码</em>欢迎支持//----------------------------------------------------------
//更多好用代码找我们交流
//论坛 www.flash127.com
//QQ群 324098841
//让梦想者聚集一起为梦努力,奋斗[梦雪论坛]!
//----------------------------------------------------------

