js设置睡眠N秒后再执行

  function sleep(NumMillis) {
        var nowTime = new Date();
        var exitTime = nowTime .getTime() + NumMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }
    }

 

转载于:https://www.cnblogs.com/bin521/p/8806914.html

你可能感兴趣的:(javascript,前端)