Steven Moss Steven Moss - 1 year ago 265
jQuery Question

wait() or sleep() function in jquery?

I want to add a class, wait 2 seconds and add another class.


Is there any way?

Answer Source

setTimeout will execute some code after a delay of some period of time (measured in milliseconds). However, an important note: because of the nature of javascript, the rest of the code continues to run after the timer is setup:


}, 2000);

// Any code here will execute immediately after the 'load' class is added to the element.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download