代码示例:(标识:eg_js_timing_settimeout_1)
<!DOCTYPE html>
<html>
<body>

<p>点击“试一试”。等待 3 秒钟,页面将提示“Hello”。</p>

<button onclick="setTimeout(myFunction, 3000);">试一试</button>

<script>
function myFunction() {
  alert('Hello');
}
</script>

</body>
</html>
运行结果: