There are several ways to do this using jQuery
, some are:
You can use setTimeOut()
of jQuery
that calls a function after a certain time or executes a code after a time (in milliseconds).
Example:
function explode(){
alert("Boom!");
}
setTimeout(explode, 2000);
Above in the code, the explode()
function will be executed in 2 seconds (2000 milliseconds).
For a better understanding, I would advise you look here documentation on this function.
You can also use animate()
which also has a similar function to be able to execute a piece of code or function in a certain time.
Example:
var x = document.getElementById('home_page');
$(x).animate({opacity:1.0},2000);
In the above example, the animate()
function will give opacity to home_page
in 2 seconds (2000 milliseconds).
For a better understanding I advise you to take a look at the official documentation here .