Can jquery animations be chained programmatically?

前端 未结 4 1337
走了就别回头了
走了就别回头了 2021-01-24 20:46

I have this code:

jQuery(\'#flash\').animate({opacity: 0.35}, 200)
                .animate({opacity: 0}, 200)
                .animate({opacity: 0.35}, 200)
            


        
4条回答
  •  鱼传尺愫
    2021-01-24 21:27

    There is a shorter alternative, using the extension jquery-timing:

    Animate a given number of times:

    $('#flash').repeat().animate({opacity:0.35}, 200)
        .animate({opacity:0}, 200).until(10);
    

    As endless loop:

    $('#flash').repeat().animate({opacity:0.35},200).animate({opacity:0},200,$);
    

    For details see the API of .repeat(), .until(count), and .animate(…,$).

提交回复
热议问题