0

我想在元素悬停时停止或清除元素的动画,并在未悬停时返回。这是我的代码:

function blink(){
        $('#unitedkingdom, #germany, #korea, #philippines,
        #indonesia').delay(400).fadeTo(800,0.7).delay(800).fadeTo(800,1, blink);
    }

    $(document).ready(function(){

            blink();

        $('#unitedkingdom').hover(function(){
            $(this).stop(blink); //I'm trying to STOP the function i declared from above
            $('#uk').animate({opacity:1},300);
        });
        $('#germany').hover(function(){
            $('#ger').animate({opacity:1},300);
        });
        $('#korea').hover(function(){
            $('#kor').animate({opacity:1},300);
        });
        $('#philippines').hover(function(){
            $('#phil').animate({opacity:1},300);
        });
        $('#indonesia').hover(function(){
            $('#ind').animate({opacity:1},300);
        });
    }); 

有解决办法吗?

4

1 回答 1

2

你要这个:

$(this).stop(true);

jQuery.stop()文档 - http://api.jquery.com/stop/

于 2012-12-28T03:31:02.503 回答