jQuery setTimeout function

If you want to delay your jQuery code to run after some amount of time, you can use JavaScript setTimeout function to delay the execution. setTimeout is used in JavaScript to delay execution of some code and the same function can be use with jQuery without any extra effort. Since jQuery is written on top of JavaScript, so you can use all JavaScript functions with jQuery as well. 

The Basic syntax for setTimeout function is,

$(document).ready(function(){ 
setTimeout(function() {
      // Do something after 5 seconds
}, 5000);
});

The setTimeout function takes the times in milliseconds’. And the block can contain either your jQuery code, or you can also make a call to any function.

For more Interesting updates Subscribe our YouTube channel: Click Here to Subscribe

Leave a comment

Design a site like this with WordPress.com
Get started