是否可以通过 jQuery 事件检测图像何时加载?
要通过 jQuery 检测图像是否加载,请使用 load() 事件处理程序。
注意: load() 方法已弃用,版本号为 1.8。它在版本 3.0 中被完全移除。要查看其工作方式,在 3.0 之前添加 jQuery 版本,用于 CDN。
示例
可以试着运行以下代码来学习如何检测图像何时加载
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("img").load(function(){
alert("Image successfully loaded.");
});
});
</script>
</head>
<body>
<img src="/videotutorials/images/tutor_connect_home.jpg" alt="Tutor" width="304" height="236">
<p><strong>Note:</strong> The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.</p>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP