Forums

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

Home Forums JavaScript .setTimout and .delay Re: .setTimout and .delay

#116684
JohnMotylJr
Participant

I can’t seem to find out how to delay the removeClass until the menu is fully collapsed. Currently, the class is removed and the box shadow is gone before it begins to retract, and I’d like to add a delay to prevent that.

Im sorry, call me ignorant but after i read this i didnt read any more.. Sounds to me like all you need is a callback function.

$('#slider span').toggle(
function() {
$('#headerNav').animate({
left: 0
}, 'slow').addClass('active');
}, function() {
$('#headerNav').animate({
left: '-90%'
}, 'slow', function() {
$(this).removeClass('active');
});
}
);​

Is this what you want?

http://jsfiddle.net/john_motyl/E62RK/