Using delay with HTML or text setting doesn’t work

delay() defaults to the animation queue, for effects like fadeOut(), etc. You should use setTimeout() instead:

window.setTimeout(function () {
    $("#element").html(' ');
}, 3000);

From http://api.jquery.com/delay/:

jQuery.delay() is best for delaying between queued jQuery effects and such, and is not a replacement for JavaScript’s native setTimeout function, which may be more appropriate for certain use cases.

Leave a Comment