Villi Magg
Villi Magg

Reputation: 1193

jQuery box fadeOut/fadeIn blinking after mouseleave

How to make this just fade out on mouseover and just fade back in again on mouseleave? My jsFiddle

$(function() {
var box = $('#box');

box.on('mouseover', function() {
    box.fadeOut(500);
});
box.on('mouseleave', function() {
    box.fadeIn(500);
});
});

Upvotes: 0

Views: 998

Answers (2)

adeneo
adeneo

Reputation: 318182

$(function() {
    $('#box').on('mouseenter mouseleave', function() {
        $(this).stop().fadeToggle();
    });
});

FIDDLE

Upvotes: 2

Manish Mishra
Manish Mishra

Reputation: 12375

try this:

$(function() {
    var box = $('#box');
    box.hover(function() {
        $(this).fadeOut(500);

    }, function() {
        $(this).stop().fadeIn(500);

    });
});

see this fiddle

Upvotes: 1

Related Questions