jQuery append in loop - DOM does not update until the end

后端 未结 4 450
感情败类
感情败类 2020-12-10 03:10

When looping over a large collection and appending it to the DOM, the DOM only refreshes after all items have been appended. Why doesn\'t the DOM update after each app

4条回答
  •  独厮守ぢ
    2020-12-10 03:39

    If that's really what you want to do...

    var i = 0;
    for (i=0; i<5000; i++) {
        setTimeout(function() {
            $('#collection').append('
  • Line Item
  • '); }, 0); }

提交回复
热议问题