Looping with .each with delay in Jquery

后端 未结 5 1031
时光说笑
时光说笑 2021-01-16 14:20

I am not good at jQuery so I am not sure if my assumptions are corrent.

I am using the isotope plugin, with which I want to insert elements one by one (and not every

5条回答
  •  执笔经年
    2021-01-16 14:42

        var $items=$("#items_are_here").find('.item');
        var i=-1;
        var delayed=setinterval(function() {
                if (++i<$items.length) $('#container').isotope( 'insert', $items.eq(i));
                else clearInterval(delayed); 
                 },3000);
    

    not tested. or

        var $container=$('#container');     
        $.fn.extend({
          onebyone :function ($ctnr,i) {
               if (!i) i = 0;
               var $o=$(this);
               setTimeOut(function() {
                     $ctnr.isotope( 'insert', $o.eq(i)); 
                     if (++i<$o.length) $o.onebyone(i); 
                   },3000);
               return this; 
          }
        $("#items_are_here").find('.item').onebyone($container);
    

提交回复
热议问题