:::: MENU ::::

Javascript setTimeout() function jquery examples and chaining it with afterTime() plugin


javascript setTimeout() function

  • It takes two arguments.
    1. callback function to execute after milliseconds supplied.
    2. milliseconds – after how many milliseconds callback function will execute?.
  • It’s asynchronous or non-blocking.

    i.e. next line after setTimeout executes immediately and doesn’t wait for callback to execute.

  • It returns handler that can be used to halt execution of setTimeout() function.

jQuery setTimeout() usage example

Button Code:-


jQuery afterTime() method to chain setTimeout() function

jQuery afterTime() method can be used to chain with jQuery selectors

Sample Usage of this plugin


Further Chaining:-  it executes jQuery append() without waiting for afterTime() callback to finish.


 Chaining of afterTime() method to execute multiple setTimeout() synchronously.


So, what do you think ?