2022-09-05 08:47:20
6阅读
<html>
<head>
</head>
<body>
<h1> Example of using sleep() in JavaScript </h1>
<script>
function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
async function fun() {
document.write('Hello World');
for (let i = 1; i <=10 ; i++) {
await sleep(2000);
document.write( i + " " + "Welcome to the javaTpoint.com" + " " + "</br>");
}
}
fun();
</script>
</body>
</html>
https://www.javatpoint.com/javascript-sleep
最后生成于
2024-05-24 22:37:29
热门推荐:
此内容有帮助 ?
0