我希望能够做一件事的document.write。然后延迟半秒,然后document.write更多。你知道这是否可能吗?如果是这样,又是如何实现的呢?到目前为止,我已经尝试过了,但没有成功:
document.write("Hello!");
setTimeout(function(){
},1000);
document.write("hello!");发布于 2013-06-02 03:46:28
因此,您需要将语句放入setTimeout中。
document.write("Hello!");
setTimeout(function(){
document.write("hello!");
},1000);setTimeout()中的第一个参数是要在延迟毫秒后执行的函数。
下面是一个jsfiddle示例(不使用document.write)
发布于 2013-06-02 03:46:00
1000毫秒=1秒
setTimeout(function(){console.log("Hello")},3000);SetTimeOut不是“暂停”。它将在一段时间后执行他自己的代码。
看看这个例子:http://www.w3schools.com/js/tryit.asp?filename=tryjs_timing1
发布于 2013-06-02 03:48:25
您可以尝试这样做:
var docWriteLater = function(){
document.write("Hello Later!");
}
setTimeout(docWriteLater, 1000)
document.write("hello now!");https://stackoverflow.com/questions/16876555
复制相似问题