delay()
methodYou can use the jQuery delay()
method to call a function after waiting for some time. Simply pass an integer value to this function to set the time interval for the delay in milliseconds.
Let's check out an example to understand how this method basically works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Execute a Function after Certain Time</title>
<style>
img{
display: none;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
function showImage(){
$("img").fadeIn(500);
}
$(document).ready(function(){
$(".show-image").click(function(){
$(this).text('loading...').delay(1000).queue(function() {
$(this).hide();
showImage(); //calling showimage() function
$(this).dequeue();
});
});
});
</script>
</head>
<body>
<button type="button" class="show-image">Show Image</button>
<img src="../images/kites.jpg" alt="Flying Kites">
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Failed to clear cache. Make sure you have the appropriate permissions in Laravel
Hi, Hello Laravel artisan. this is...How to Setup 404 Page in Angular 12
In this article, we will create 404 erro...How to Create REST API in Laravel7 using Passport
Hey Artisan Hope you are doing well....Copy text to clipboard with clipboard.js
When working on front-end side, we alway...Line Breaks For Textarea Text in Laravel Blade
Hi, in this article i will show you how...