FadeIn and fadeOut repeat

2019-08-26 03:08发布

问题:

When I quickly click a #div several times, fadeIn and fadeOut is performed several times. I would like the animation is not repeated, if I quickly click #div animation perform only one time.

Code:

$("#div").click(function(){
    $("#information").fadeIn(1200).fadeOut(1200);
});

Sorry for my english ;)

回答1:

Try using .stop()

$("#information").stop(true, true).fadeIn(1200).fadeOut(1200);

Demo ---> http://jsfiddle.net/S48RU/