Reputation: 2387
Is there a way to stop an fadeOut()
animation on mouseleave
in jQuery?
I want the script to work like:
This is what i'm working at:
$(document).ready(function(){
$('.this').hover(function(){
$('#container').fadeIn(200);
}).mouseleave(function(){
setTimeout(function () {
$('#container').fadeOut(200);
}, 1000);
})
$('#container').hover(function(){
$('#container').stop().show();
})
});
Upvotes: 1
Views: 2752
Reputation: 7250
Like this? http://jsfiddle.net/y36ta/6/
var $container = $('#container');
$('.this').on('mouseover', function(){
$container.stop(true).fadeIn(200);
}).on('mouseleave', function(){
$container.stop(true).delay(200).fadeOut(200);
})
$container.on('mouseenter', function(){
$(this).stop(true).clearQueue().show();
}).on('mouseleave', function() {
$(this).delay(200).fadeOut(200);
});
Update: use .on()
to bind handlers.
Upvotes: 6
Reputation: 5454
Heres a jsfiddle. check it out, I think it's what you need.
$(document).ready(function() {
$('a').hover(function() {
$('.this').stop().fadeTo(200, 1, function(){
$('.this').fadeTo(800, 0.1);
});
}, function() {
$('.this').stop().fadeTo(200, 0.1);
});
});
hope it helps
Upvotes: 1