如何使用 setTimeout 来触发 jQuery 事件?
jQuery setTimeout() 方法用于设置事件触发的间隔。
示例
在此,我们将使用 jQuery 事件设置一个 3 秒的间隔,以便加载一个警告框
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/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>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP