jQuery Delay() not Working?
.delay() is only designed to work with animations ( like fadeOut(),slideUp ( ), animate() etc.). Calls to any manipulation functions (html(), append(), css() etc.) will completely ignore your delay() call, because there are all executed immediately, and not queued at all. You’ll have to resort to using regular set timeouts for what you’re doing:var li = $('.articles).addClass('green');
setTimeout(function ( ) {
li.removeClass('green');
}, 4500);
If setTimeout is not bringing the exact timeshift you needed to get the manipulation done go for the proper method of queueing – .queue ( )
var li = $('.articles).addClass('green')
.delay(4500)
.queue(function() {
$(this).removeClass("go");
$(this).dequeue();
});

Post a Comment