We can use the jQuery fadeOut
method to hide a div.
And we can combine that with setTimeout
to delay the execution of fadeOut
.
If we have the following HTML:
<div id='mydiv'>
hello world
</div>
Then we can call fadeOut
by writing:
setTimeout(() => {
$('#mydiv').fadeOut('fast');
}, 1000);
We call fadeOut
in the setTimeout
callback with a delay of 1000 milliseconds.
And now we should see the div fade away after 1 second.