简体   繁体   中英

What's wrong with my JQuery?

I tried this code, which worked the first time. But for some reason it didn't work after. I don't get it.

The code is as follows:

$(document).ready(function(){    
    $("#blue").mouseenter(function(){    
        $("#pink").slideDown("normal", function(){    
            $("#green").animate({width:'toggle'});
        });
    });
    $("#green").mouseleave(function(){
        $("#green").animate({width:'toggle'}, function(){
            $("#pink").slideUp();
        });
    });
});

What I'm trying to do is have one slide event for when you hover to and from the designated area. This seems to malfunction for reasons that I'm not sure.

JS Fiddle: http://jsfiddle.net/vL65X/

The animations get queued. Try using .stop() or .clearQueue() ...

edit: looked up the doco.

$("#blue").mouseenter(function(){
    $("#pink").stop().slideDown("normal", function(){
    $("#green").stop().animate({width:'toggle'});
        });     
    });
$("#green").mouseleave(function(){
    $("#green").stop().animate({width:'toggle'}, function(){
    $("#pink").stop().slideUp();
        });     
    }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM