jQuerysetTimeout()方法用于设置触发事件的时间间隔。
在这里,我们将为警报框设置3秒的间隔,以便使用jQuery事件进行加载:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#button1").click(function(){
setTimeout("alert('Hello World!');", 3000);
});
});
</script>
</head>
<body>
<button id="button1">Click</button>
<p>Click the above button and wait for 3 seconds. An alert box will generate after 3 seconds.</p>
<p></p>
</body>
</html>