问题
How to make a non-blocking sleep in javascript/jquery?
回答1:
At the risk of stealing the answer from your commentors, use setTimeout(). For example:
var aWhile = 5000; // 5 seconds
var doSomethingAfterAWhile = function() {
// do something
}
setTimeout( doSomethingAfterAWhile, aWhile );
来源:https://stackoverflow.com/questions/7729382/how-to-make-a-non-blocking-sleep-in-javascript-jquery