h5monkey

效果图:

代码:

 $(function() {
            var Time = 10,
                t;
            var c = Time
            $("#fsyzm").on("click", function() {
                console.log("开始了");
                timedCount();
            })

            function timedCount() {
                $(\'#fsyzm\').val("请稍等(" + c + ")");
                $(\'#fsyzm\').attr("disabled", "disabled");
                c = c - 1;
                t = setTimeout(function() {
                    timedCount();
                }, 1000);
                if (c < 0) {
                    c = Time;
                    stopCount();
                    $(\'#fsyzm\').val("发送校验码");
                    $(\'#fsyzm\').removeAttr("disabled");

                }
            }

            function stopCount() {
                clearTimeout(t);
            }
        })

 升级版本 防止刷新

 

分类:

技术点:

相关文章: