js 카운트다운 60s

2921 단어




    
    
    
    
    
    
    
    
    
     
    




    
          




    $(function () {
        var send=$(".getVerificationCode"),timer=null,wait=60;
        function time() {
            if (wait == 0) {
                send.prop("disabled",false);
                send.text(" ");
                send.css({background:"#9cc829"});
                clearTimeout(timer);
                timer=null;
                wait=60;
            } else {
                send.prop("disabled", true);
                send.text(" (" + wait + ")");
                send.css({background:"#a5a5a5"});
                wait--;
                timer=setTimeout(time, 1000);
            }
        }
        time();
        // --- 
        $(".buttonClick").click(function () {
            // utils.error(" ");

        });
    });

// 
// 0
        function timeS(num) {
            return ('0' + num).slice(-2);
        }
        function moveTime() {

            var starttime = $(".w_sp2").attr("starttime").replace(/-/g, '/');
            var endtime = $(".w_sp2").attr("endtime").replace(/-/g, '/'); // new Date('2013-10-21'), new Date('2013/10/21');
            var startTime = new Date(starttime).getTime();
            var endTime = new Date(endtime).getTime();
            var differTime = endTime - startTime; // 
            
            function FreshTime() {

                var d = parseInt(differTime / (24 * 60 * 60 * 1000));
                var h = parseInt(differTime / (60 * 60 * 1000) % 24);
                var m = parseInt(differTime / (60 * 1000) % 60);
                var s = parseInt(differTime / 1000 % 60);
                var t_html = d + " " + timeS(h) + " " + timeS(m) + " " + timeS(s) + " ";
                $(".w_sp2").html(t_html);
                if (differTime <= 0) {
                    $(".w_sp2").html(' ');
                    $(".i_contThr").hide()
                    clearInterval(timer);
                }
                differTime = differTime - 1000;
            }
            FreshTime();
            var timer = setInterval(FreshTime, 1000);
        }

좋은 웹페이지 즐겨찾기