delay() MethodThe delay() method in jQuery is used to pause the execution of animations or effects for a specified amount of time before continuing.
The delay() method inserts a delay in the animation queue.
Syntax: $(selector).delay(time)
// Delay hiding the box by 2 seconds
$(document).ready(function(){
$("#btn").click(function(){
$("#box").delay(2000).fadeOut();
});
});
When the button is clicked, the box waits for 2 seconds and then smoothly fades out.
// Interactive delay animation example
$("#btn").on("click",function(){
$("#box").delay(1000).slideUp().delay(1000).slideDown();
});
delay() only with animationsfadeIn() or slideUp()animate()