我正在尝试编写一个脚本,该脚本在图像加载时显示加载器 gif 图像,但在包含该脚本后 firefox 页面中没有任何图像。它在 chrome 中运行良好。我包含了以下代码。
Javascript:
<script>
$(window).load(function() {
$('#loader').hide();
$('#best').fadeIn();
});
</script>
HTML:
<body>
<div id="loader"></div>
<div id="best">
<!-- Contents of the page here -->
</div>
</body>
CSS:
#loader {
background: url('img/19-0.gif');
height: 95px;
width: 95px;
position: relative;
top: 50%;
left: 50%;
margin-top: 15em;
margin-left: 13em;
}
#best {
display: none;
}
我的代码是否有任何问题,或者我应该尝试其他方法吗?
最佳答案
试试这个:
$(document).ready(function() {
$('#loader').hide();
$('#best').fadeIn();
});
关于javascript - $(window).load 在 Firefox 中不显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17945139/