zoukankan      html  css  js  c++  java
  • 倒计时

    /*倒计时
    var countdown=(function(){
        return function(){
        var showTime = document.getElementById(this.id),
            beginNum=60,
            oril=showTime.innerHTML,
            string="%t%u79d2u540eu53efu91cdu65b0u64cdu4f5c",
            t;
        var showDown=function(){
            if(beginNum>0){
                beginNum-=1;
                showTime.innerHTML = string.replace("%t%",beginNum);
                showTime.disabled="disabled";
            }else{
                showTime.innerHTML =oril;
                clearInterval(t);
                showTime.disabled="";
            }
        };    
        t=setInterval(showDown,1000);
        };
    })();
    */
    (function($) {
      $.fn.countdown = function(options) {
        var opts = $.extend(true, {},
        $.fn.countdown.defaults, options);
        return this.each(function() {
            var $this = $(this);
            var t,beginNum=60,oril=$this.html(),
                string="%t%u79d2u540eu53efu91cdu65b0u64cdu4f5c";
            function countdown(){
                    return function(e){
                        var origNum=beginNum;
                        $this.html(string.replace("%t%",beginNum));
                        $this.addClass("getCodeOff");
                        $this.attr("disabled",true);                    
                        var showDown=function(){
                            if(beginNum>0){
                                beginNum-=1;
                                $this.html(string.replace("%t%",beginNum));
                            }else{
                                beginNum=origNum;
                                $this.html(oril);
                                $this.removeClass("getCodeOff");
                                $this.attr("disabled",false);
                                clearInterval(t);
                            }
                        };    
                        t=window.setInterval(showDown,1000);
                    };
                };
        $this.on("click",countdown());        
        });
      };
      $.fn.countdown.defaults = {
      };
    })(jQuery);
  • 相关阅读:
    批处理操作
    注册表操作
    js 表格操作(兼容模式
    asp解码.net传参
    windows+nginx 查看并发链接数
    windows+nginx负载测试
    开发cocos2dx真机插件遇到问题,以及心得
    react路由
    Redux实现原理解析及应用
    test
  • 原文地址:https://www.cnblogs.com/dingyuanxin/p/4120294.html
Copyright © 2011-2022 走看看