Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Delay a hover affect Re: Delay a hover affect

#74363
noahgelman
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();
}
);