views:

23

answers:

2

Hey Guys,

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 the 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;
            });
+2  A: 

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

jorgebg
ok but on mouseleave or where do I have to place it?
lain
thanks works for me <3
lain
A: 
$("#page-bar > ul > li").mouseenter(function(){
      $(this).stop().animate({
                    backgroundColor: "#3c78a7"
                }),500;
            }).mouseleave(function(){
                $(this).stop().animate({
                    backgroundColor: "#333333"
                }),500;
            });
Gabriel Guimarães