Stop jQuery animations stacking

前端 未结 4 2023
误落风尘
误落风尘 2021-01-03 07:43

I have an Options box that hovers in the top right of the webpage. It\'s opacity is set to 10% so as not to be obstructive to users. When they hover over (mouseenter) it I

4条回答
  •  遥遥无期
    2021-01-03 08:41

    Call stop to terminate any existing animations before starting a new one. You should also probably use hover instead of mouseenter/mouseleave.

    $("#dropdown").hover(function() {  
        $(this).stop().fadeTo('fast',1); 
        $("#options").stop().slideDown(); 
    }, function() {  
        $(this).stop().fadeTo('fast',0.1); 
        $("#options").stop().slideUp(); 
    });
    

提交回复
热议问题