Execute jQuery code after all CSS rules have been applied

自闭症网瘾萝莉.ら 提交于 2020-01-11 05:15:09

问题


$(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.


回答1:


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




回答2:


$(window).load(function() {

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

 alert("window is loaded");

});


来源:https://stackoverflow.com/questions/4441384/execute-jquery-code-after-all-css-rules-have-been-applied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!