$.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) };