加载完成前隐藏 -jquery
我尝试使用此代码来隐藏正文,并显示何时完整加载。但我注意到这效果不佳,因为当发生淡入淡出时,某些图像尚未加载。
我怎样才能做出这样的效果?
<script type="text/javascript">
$(document).ready(function(){
$('.nav').fadeIn(700);
});
</script>
<body class="nav" style="display: none">
I have tried this code to hide the body, and show when is loaded in totality. But I noticed that is not working well, because when the fade occurs, some images are not yet loaded.
How I can do this effect?
<script type="text/javascript">
$(document).ready(function(){
$('.nav').fadeIn(700);
});
</script>
<body class="nav" style="display: none">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,它很简单:
Surely it's as simple as:
如果您想等待图像(有问题的想法,但这是您的网站),您可以只处理“加载”事件:
我说这是一个有问题的想法,因为可能需要一些时间才能获取图像,这可能是令人困惑。不过,我当然不知道你的网站是什么样子,所以也许没问题。
哦,还有:如果您真的只是针对 body 元素,那么您可以使用
Not that it important at all in this context,但这会更有效。
If you want to wait for the images (questionable idea, but it's your site) you can just handle the "load" event instead:
I say that that's a questionable idea because it may take some time to get the images, and that may be confusing. However, I don't have any clue what your site looks like, of course, so perhaps it's fine.
Oh, also: if you're really just targetting the body element, then you can just use
Not that it matters at all in this context, but that's going to be more efficient.