setTimeout() Method

By: Dusty Arlia
Published on Thursday, June 20, 2013, 08:06 AM
Last Updated on Wednesday, July 15, 2015 at 12:52 PM
Total Updates: 3

The setTimeout() JavaScript method is great for setting a timed execution of a function. For example, you can execute a function two seconds after a webpage loads or a button is clicked. Here is the basic syntax of the setTimeout() method:

setTimeout([your function],milliseconds);

The setTimeout() method will wait a certain amount of milliseconds specified by the second argument (every thousand milliseconds equals one second) and then execute the specified function (the first argument).

Here is an example:

setTimeout(function(){alert("Welcome To Our Site!")},2000);

Comments:

Ad: