Ok, I give up. After trying to google and changing my code. I'm going to ask this here. I have a click function .navTrigger
which displays my nav menu's li
one after another. This is working like it should.
Only when I click on the .navTrigger
again I would like to have it fadeOut
again (It would be awesome if it could be with a delay again). I just can't get my head around how to get this working? (probably pretty simple)...
Here is my code:
$('.navTrigger').click(function() {
$(this).toggleClass('active');
var delay = 1000;
$('nav ul > li a').each(function() {
$(this).delay(delay).fadeIn(500);
delay += 400;
});
});
I have tried replacing toggleClass
with addClass
and then add
if ($('.navTrigger').hasClass('active')) {
var delay = 1000;
$('nav ul > li a').each(function() {
$(this).delay(delay).fadeIn(500);
delay += 400;
});
} else {
var delay = 1000;
$('nav ul > li a').each(function() {
$(this).delay(delay).fadeOut(500);
delay += 400;
});
}
But yeah, that didn't work either... any help would be awesome!