setTimeout inside $.each()

前端 未结 4 1822
借酒劲吻你
借酒劲吻你 2021-02-07 13:02

ok, so I\'ve got this code:

$(this).find(\'article.loading\').each( function(i) {

    var el = this;
        setTimeout(function () {
        $(el).replaceWith(         


        
4条回答
  •  忘了有多久
    2021-02-07 13:36

    I just modify your code and make a little change. Just a little trick.

    $(this).find('article.loading').each( function(k, v) {
        var el = this;
            setTimeout(function () {
            $(el).replaceWith($('#dumpster article:first'));
        }, k*speed);
    });
    

    P.S. This solution is not the optimize solution but it help you to get job done fast. In most case it's fine. Just like jquery itself.

提交回复
热议问题