jQuery each() with a delay

前端 未结 5 2010
执念已碎
执念已碎 2021-02-07 08:33

So, I would like an element to fade in and wait half a second, then fade the next in etc...

My code:

$(\'.comment\').each(function() {                 
          


        
5条回答
  •  孤独总比滥情好
    2021-02-07 09:31

    Try this out:

    var time = 500;
    $('.comment').each(function() {                 
         var $this  = $(this);
        function delayed() {
             $this.css({'opacity':0.0}).animate({
                        'opacity':1.0
                    }, 450);
         }
        setTimeout( delayed , time );
        time += 500;
     });
    

提交回复
热议问题