$(function () { $('body').append(''); $('body').append(''); }); $('body').on('click', '.mobyz .btn-b', function () { btn = $(this); btn.addClass('moveloading').attr("disabled", "true"); $.post("/home/userfun.php", $(this).parents("form").serialize(), function (sc) { btn.removeAttr("disabled").removeClass('moveloading'); spop({ template: sc.msg, style: sc.s, autoclose: 3000 }); if (sc.s == "success") { $('.mobyz').remove(); } }, 'json'); }); var ctime = 120; $("body").on('click', ".mobyz .sedmsg", function (e) { var b = this, btn = $(this); btn.addClass('moveloading').attr("disabled", "true"); var checkcode = $("input[name='checkcode']").val(), mob = $("input[name='mob']").val(); $.post("/home/action.php", { a: 'sendmsgcode', checkcode: checkcode, mob: mob }, function (sc) { btn.removeAttr("disabled").removeClass('moveloading'); spop({ template: sc.t, style: sc.s, autoclose: 3000 }); if (sc.s == "success") { setTime(b); } }, "json"); }) function setTime(a) { if (ctime === 0) { a.innerHTML = "发送"; a.disabled = false; ctime = 120; clearTimeout(b); } else { ctime--; a.innerHTML = "发送(" + ctime + ")"; a.disabled = true; var b = setTimeout(function () { setTime(a); }, 1000); } }