阅读422 返回首页    go iPhone_iPad_Mac_apple


javascript 延时执行函数

延时执行函数,貌似有些多此一举, 也许还是有点用 记在这儿

var test = {
    delay : function(lifetime){
            var data;
            setTimeout(function(){
                    for (name in test.methods) {
                        eval("data = test.methods."+ name +"();");
                    }
                }, lifetime);
            return this;
        },
    methods : {},
    register : function(name, callback){
            eval("this.methods."+ name +" = callback;");
            return this;
        },
    output1 : function(message){
            this.register("output1", function(){ alert(message); });
            return this;
        },
    output2 : function(message){
            this.register("output2", function(){ alert(message); });
            return this;
        }
}
test.delay(3000).output1("aaa").output2("bbb");


最后更新:2017-04-03 12:54:58

  上一篇:go 浏览器 CSS 兼容写法的测试总结
  下一篇:go PHP截取含中文的混合字符串长度的函数