Using jQuery delay() with css()

delay() works with the animation (fx) queue. Changing a css property does not work via that mechanism, and thus is not affected by the delay directive.

There is a workaround — you can inject the property change as a queued operation, like this:

$('#tip')
  .delay(800)
  .queue(function (next) { 
    $(this).css('display', 'none'); 
    next(); 
  });

Also, you should probably be using .hide() instead of .css('display','none').

Here’s a working example: http://jsfiddle.net/redler/DgL3m/

Leave a Comment