我有以下$ .each循环一个对象。每5秒调用一次get_file()函数。是否有包含暂停和恢复选项。所以,如果我点击暂停数据加载停止。当然,当我点击一个继续按钮时,它会从停止的地方再次启动。在一个循环中暂停和恢复setTimeout
希望有人能帮忙。
$.each(obj, function (i, v) {
setTimeout(function() {
file = v.new_file;
var timeline_date = moment(v.last_modified_date).format("dddd, MMMM Do YYYY, h:mm:ss a");
bHover = 0; //re-highlight links
$(".timeline_msg").html(timeline_date);
get_file(file);
}, 5000 * (i + 1));
});
的[创建在JavaScript在while循环中的暂停(http://stackoverflow.com/questions/4548034/create-a可能重复-duse-while-loop-in-javascript) – bencripps 2014-11-02 04:02:11