How to pause javascript code.

Javascript doesn't have a sleep or pause function, it has setTimeout.

Syntax:

setTimeout(function(){ 
}, 2000);

The code that needs to run after a pause needs to be in the callback method of the setTimout function.

Example:

// code before the pause
setTimeout(function(){
    // code running after the pause
}, 2000);


References:

jQuery

Recent Comments