"where does this belong then? " <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { //Fires when the DOM is ready }); $(window).load(function() { //Fires when the page is loaded //(images all loaded, DOM objects placed/sized, etc) }); </script> </head> <body> .. Your HTML ... </body> </html>
On Feb 3, 4:47 pm, kim3er <rich...@dogma.co.uk> wrote: > $(document).ready() fires when the document has finished loading. It > is generally appropirate to attach any onload code to that event. If > you need to attach code to the window load event, do so at the top of > the page before the page has started rendering. > > Rich > > On Feb 3, 9:30 pm, eagleon <antonypei...@gmail.com> wrote: > > > thanks for the reply, I got it to work without the $(window).load > > () ... but just to learn, where does this belong then? > > > On Feb 3, 4:26 pm, MorningZ <morni...@gmail.com> wrote: > > > > Don't put > > > > $(window).load() > > > > inside > > > > $(document).ready() > > > > On Feb 3, 4:12 pm, eagleon <antonypei...@gmail.com> wrote: > > > > > Hi Guys, > > > > > I was trying to fire an $.css() during the onload event. For some > > > > reason, it does not work. It works fine if I attach it to another > > > > event such as a resize event, but not onload. > > > > > This is what I have done: > > > > > Code: > > > > [code] > > > > function myFunc() { > > > > > $("#example").css({'width' : 10px;}); > > > > > } > > > > > $(document).ready(function() { > > > > > $(window).load(function() { > > > > > myFunc(); > > > > > }); > > > > > }); > > > > > [/code] > > > > > I need this element to be sized immediately after loading. This works > > > > if the event was anything else, but dosen't work with 'load' at all. > > > > > Please help! > > > > > Thanks