用JS实现延时函数sleep()代码
var sleep = function(time) { var startTime = new Date().getTime() + parseInt(time, 10); while(new Date().getTime() < startTime) {}}; sleep(1000); // 延时函数,单位ms
var sleep = function(time) { var startTime = new Date().getTime() + parseInt(time, 10); while(new Date().getTime() < startTime) {}};
sleep(1000); // 延时函数,单位ms