Thursday, July 4, 2013

Javascript - Delay the execution a function

If for some reasons you want to delay the execution of a javascript function, you just need to use setTimeout, the pure built-in javascript function which is compatible with all browsers:

* Function without parameters:

setTimeout(function_name, 1000);

* Function with parameters:

setTimeout(function() { function_name(params) }, 1000);