append2 给append 添加回调方法

   $.fn.append2 = function(html, callback) {
        var originalHtmlLength = $("body").html().length;
        this.append(html);
        var nums = 1;
        var timer1 = setInterval(function() {
            nums++;
            var clearIntervalfun = function() {
                clearInterval(timer1)
                callback();
            } 
            var flag = originalHtmlLength != $("body").html().length || nums > 1000;
            // console.info("append html expend {0}ms".format(nums))
            flag && clearIntervalfun()

        }, 1)
    };

 

posted @ 2014-08-22 18:21  王大湿  阅读(819)  评论(0编辑  收藏  举报