The jQuery setTimeout()
method or setTimeout function is used to set an interval for events to fire.
An alternative syntax that allows you to include a string instead of a function, which is compiled and executed when the timer expires.
Syntax for setTimeout function
setTimeout(function, milliseconds, param1, param2, ...)
Parameters
Parameter | Description |
function | Required. The function to execute. |
milliseconds | Optional. Number of milliseconds to wait before executing. Default value is 0. |
param1, param2, … | Optional. Parameters to pass to the function. |
Examples
We will set an interval of 3 seconds for the alert box using jQuery events.
<script> $(document).ready(function(){ $("#button1").click(function(){ setTimeout("alert('Hello World!');", 3000); }); }); </script>
You can get more details about this topic from here.
To get to know more about other JQuery topics, you can check these articles too.
Please follow and like us: