我的网站使用以下代码:
<script src="js/jquery-1.10.1.js" type="text/javascript"></script>
<script src="js/jquery-migrate-1.2.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("img#logo").load(function() {
alert('Hello');
});
});
</script>
这在 IE 中不起作用,但在 Firefox、Chrome 和 Safari 中运行良好。
最佳答案
我可以确认您的代码确实可以在使用未缩小版本的 Windows 7 64 上的 IE 8 中运行:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript" src="jquery-1.10.1.js"></script>
<script>
$(document).ready(function () {
console.log($.fn.jquery);
$("img#logo").load(function () {
console.log('Hello');
});
});
</script>
</head>
<body>
<img id="logo" src="somegig.gif" onload="console.log('load');"/>
</body>
</html>
这将记录 1.10.1,然后加载,然后您好,也许您必须验证您的 html 并确保您的 html 有效,也许这是一个问题。
关于javascript - JQuery .load() 在 Internet Explorer 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17376921/