jQuery:$(document).ready() 在 IE 中太慢
在呈现页面之前隐藏元素的首选方法是什么? $(document).ready() 在 Firefox 中工作得很好,但有时(与服务器的连接似乎是一个主要问题)它在 Internet Explorer 中有点落后; 该元素被显示,并在不久后隐藏。 也就是说:页面在 $(document).ready() 中的代码执行之前呈现。
现在我一直在浏览之前关于类似问题提出的问题,但据报道这些问题已在 1.3.1 中得到解决。 然而,我正在使用 jQuery 1.3.2 并遇到这种行为(在 IE6、IE7 和 IE8 中)。
一种可能的选择是通过 css 默认隐藏它,但这将使其显示依赖于启用 JavaScript。 我现在还不愿意这么做。
我还尝试将我的 javascript 移到 /body 标记上方,但这似乎也没有帮助。
What would be the preferred way of hiding an element before the page is rendered?
$(document).ready() works just fine for firefox, but sometimes (connection to the server seems to be a major issue in this) it lags a little behind in internet explorer; the element is shown, and hidden shortly after wards. That is: the page is rendered before code in $(document).ready() is executed.
Now I've been looking through previously asked questions on SO about similar issues, but these are reported to be solved in 1.3.1. I am however, using jQuery 1.3.2 and experiencing this behavior (in IE6, IE7 and IE8).
One possible option would be to hide it by default through css, but this would make showing it dependent of having javascript enabled. I'm not willing to do that just yet.
I have also tried to move my javascript just above the /body tag, which doesn't seem to help either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哇,这将是一个很快的...
此文档准确地显示了我正在寻找的内容,我希望有一天它能对某人有所帮助:)
Wow, this is going to be a quick one...
This document shows exactly what I was looking for, I hope it'll help someone some day :)