7

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

takeshin
  • 49,108
  • 32
  • 120
  • 164
  • $(document).ready() This line means the jQuery should only start executing once your entire page is loaded. There may be an issue with the CSS. – Matt Asbury Dec 14 '10 at 16:22
  • window.load should do , it will till all the images loads also – kobe Dec 14 '10 at 16:23

2 Answers2

11

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

Emmett
  • 14,035
  • 12
  • 56
  • 81
2
$(window).load(function() {

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

 alert("window is loaded");

});
kobe
  • 15,671
  • 15
  • 64
  • 91