0

我有这个 jQuery:

 $(function() {
        // create the image rotator
        var lightShow = setInterval(rotateImages, 500);


    function rotateImages() {

        var oCurPhoto = $('#photoShow div.current');
        var oNxtPhoto = oCurPhoto.next();

        if (oNxtPhoto.length == 0){
oNxtPhoto = $('#photoShow div:first');
}


        oCurPhoto.removeClass('current').addClass('previous');

oNxtPhoto.hide().addClass('current').fadeIn(2000, function() {

oCurPhoto.removeClass('previous');
 });


    }
    });

它包含在一个循环中,因此该行将连续执行 5 次
但我想要做的是停止使用循环启动fadeIn另一个的效果。fadeIn

4

1 回答 1

0

您应该在要停止淡入淡出的元素上淡入淡出之前使用 .stop() 。

它将清除任何动画的队列。请记住,它还将阻止淡入淡出进入其回调函数。

在此处了解更多信息:.stop() - jQuery API

于 2012-06-07T11:29:31.793 回答