标签:
<script src="js/zepto.min.js"></script>
<script>
$(function () {
$("#getCode").on("click", function () {
fn_sendSMS();
});
function fn_sendSMS()
{
$("#getCode").text("5秒后重新发送").addClass("disabled").off("click");
intervalId = setInterval(function () {
var target = $("#getCode");
var num = /^\d{1,2}/.exec(target.text());
var currentSecond = parseInt(num[0]);
if (currentSecond == 1) {
target.text("重新发送").removeClass("disabled").on({ "click": fn_sendSMS });
clearInterval(intervalId);
} else {
target.text((--currentSecond) + "秒后重新发送");
}
}, 1000);
}
});
</script>
标签:
原文地址:http://www.cnblogs.com/jason-xiao/p/5651846.html