My problem is that when I move mouse quickly over square element and then go out with my cursor it sometimes doesn’t finish the “mouseout” part of hover function
My HTML:
<div id="wrapper">
<div id="o1" class="square"></div>
<div id="o2" class="square"></div>
</div>
CSS
#wrapper {
width: 100px;
height: 100px;
position: relative;
}
.square {
width: 100px;
height: 100px;
position: absolute;
}
#o1 {
background: red;
}
#o2 {
background: blue;
display:none;
}
Javascript:
$(function(){
var o1 = $("#o1");
var o2 = $("#o2");
$('#wrapper').hover(function() {
o1.fadeOut(400,function () {
o2.fadeIn(400);
});
}, function() {
o2.fadeOut(400,function () {
o1.fadeIn(400);
});
});
});
jsFiddle: http://jsfiddle.net/TQ37t/
I have tried using stop() with different parameter on different places in my code but without success. Thanks
The easiest solution I came up with was to make sure all the queues were stopped before adding any new animations:
Note that order matters when stopping the queues. Consider the following sequence: