jquery - how to make a sleep in javascript? -


Do anyone know how I can sleep in JavaScript before reading the next line through the system?

Example:

  1 var chkResult = Validation (); 2 // Sleep here for the first 10 seconds of the next line 3 4 document.getElementById ('abc'). InnerHTML = chkResult;  

For this example, how can I wait for Javascript sleep / line 2 for 10 seconds before continuing to read Line 4? I tried the set timeout ('', 10000); But it is still not working for me ...

has given the correct signal 10 seconds Use this to execute your next line code after:

  var chkResult = Validation (); Var timeout = window.setTimeout (function () {document.getElementById ('abc'). InnerHTML = chkResult;}, 10000);  

Collecting timeout IDs in one variable can be easy if you want to.


Comments