1

次のコードがあります。

$(document).ready(function(){
$('.active-bean-bag ul li.bean-bag-image').mouseover(function() {
        var activeBeanBag = 'menu-' + $(this).attr("id");
        $('.active-bean-bag img.menu-image').stop(true, true).fadeOut();
        $('.active-bean-bag img.menu-image').fadeOut(function(){
                $('.active-bean-bag img.menu-image').attr("src", '/skins/template/customer/images/'+activeBeanBag+'.png');
                $('.active-bean-bag img.menu-image').fadeIn();
        });
});

});

ただし、必要なオプションに到達するためにliオプションをすばやく移動すると、追いつかず、誤った画像が表示されます

前もって感謝します

4

1 に答える 1

1

最初に停止機能を使用してください。これにより、キューに入れられたアニメーションがキャンセルされます。

$('.selector').stop(true, true).fadeOut();

編集:: このコードを試してください:

$(document).ready(function(){
$('.active-bean-bag ul li.bean-bag-image').mouseover(function() {
        var activeBeanBag = 'menu-' + $(this).attr("id");
        $('.active-bean-bag img.menu-image').stop(true, true).fadeOut(function(){
                $('.active-bean-bag img.menu-image').attr("src", '/skins/template/customer/images/'+activeBeanBag+'.png');
                $('.active-bean-bag img.menu-image').stop(true, true).fadeIn();
        });
});
于 2012-12-30T12:41:50.237 に答える