应用所有 CSS 规则后执行 jQuery 代码

发布于 2024-10-07 17:22:34 字数 242 浏览 6 评论 0原文

$(document).ready() 在加载所有 HTML 元素后执行代码。

应用所有 CSS 规则后如何执行 jQuery 代码?

我几乎没有链接到该页面的样式表,并且加载该页面需要一些时间。元素布局在加载期间发生变化。

出于可用性目的,我需要在所有元素都有目标大小后更正元素布局。否则我会得到这些元素的错误大小。

现在我在焦点上或超时后执行此操作,但在页面加载后需要此操作。

$(document).ready() executes the code when all HTML elements have been loaded.

How to execute jQuery code after all of the CSS rules have been applied?

I have few stylesheets linked to the page and it takes some time to load the page. Element layout changes during the time of the loading.

For usability purposes I need to correct the element layout after all of them have target sizes. Otherwise I get wrong sizes of those elements.

Now I do it on focus or after some timeout, but need this after the page loads.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赠佳期 2024-10-14 17:22:34

$(window).load() 在整个页面(图像、CSS 等)加载后触发。

$(window).load() fires after the whole page (images, CSS, etc.) has loaded.

撕心裂肺的伤痛 2024-10-14 17:22:34
$(window).load(function() {

 // executes when complete page is fully loaded, including all frames, objects and images

 alert("window is loaded");

});
$(window).load(function() {

 // executes when complete page is fully loaded, including all frames, objects and images

 alert("window is loaded");

});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文