开发者

Jquery Animation Problem

开发者 https://www.devze.com 2023-01-11 12:48 出处:网络
I wonder how I can fix this propabably easy problem. Ive installed the color plugin for a smooth change of the backgroundcolor. So but when Im hovering over it a few times in a short amount of time,

I wonder how I can fix this propabably easy problem.

Ive installed the color plugin for a smooth change of the backgroundcolor. So but when Im hovering over it a few times in a short amount of time, it'll repeat and repeat t开发者_如何学Che animation like its a stack. How can I fix that? Any idea?

$("#page-bar > ul > li").mouseenter(function(){
      $(this).animate({
                    backgroundColor: "#3c78a7"
                }),500;
            }).mouseleave(function(){
                $(this).animate({
                    backgroundColor: "#333333"
                }),500;
            });


Use stop() to stop the current animation for the element. http://api.jquery.com/stop/


$("#page-bar > ul > li").mouseenter(function(){
      $(this).stop().animate({
                    backgroundColor: "#3c78a7"
                }),500;
            }).mouseleave(function(){
                $(this).stop().animate({
                    backgroundColor: "#333333"
                }),500;
            });
0

精彩评论

暂无评论...
验证码 换一张
取 消