【发布时间】:2014-07-02 12:58:57
【问题描述】:
下面的代码获取一段包含一定行数的 html。其中一些行属于 newentry 类。 (class="newentry")
我期待我的代码以 1000 米的延迟显示它们,但它们都同时出现。为什么setTimeout 在每次调用每行fadeIn() 之间没有等待?
$.ajax({
url: "@{Live.live(event.mnemonic)}",
success: function(data) {
var wait =0;
$("#results").html(data);
wait =500;
$(".newentry").each(function(){
setTimeout(function() { $('#'+this.id).fadeIn(); }, wait);
wait += 1000;
});
}
setTimeout('tick()', 1700-wait);
}
});
【问题讨论】:
标签: ajax settimeout fadein