Home › Forums › JavaScript › Delay a hover affect › Re: Delay a hover affect
November 19, 2010 at 12:47 pm
#74363
Participant
Okay, this is what I have so far, but it’s not working. Basically, when .select-dropdown is hovered, it gets a ready class. That works fine. Then I try to say that when you hover it, wait 1 second, and if it has the ready class still, show .select-options, but it’s not working. Something is wrong with my if statement.
$('.select-dropdown').hover(
function () {
$(this).addClass('ready');
},
function () {
$(this).removeClass('ready');
}
);
$('.select-dropdown').hover(
function () {
$(this).delay(1000, function() {
if ($(this).hasClass('ready'))
{
$(this).children('.select-options').fadeIn(1);
}
});
},
function () {
$(this).children('.select-options').delay(100).fadeOut();
}
);