This answer is just useful for understanding how you can delay with the jQuery delay function.
Imagine that you have a warning and want to set the warning text, then show the warning and hide it after a few seconds.
Here is a simple solution:
$(".alert-element").html("I'm the alert text").fadeIn(500).delay(5000).fadeOut(1000);
It's simple:
.html() will change the text .alert-element.fadeIn(500) will fade after 500 milliseconds- The jQuery
delay(5000) function will make a 5000 millisecond delay before calling the next function. .fadeOut(1000) at the end of the instruction .alert-element will disappear
M98 Jul 31 '16 at 12:55 2016-07-31 12:55
source share