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

Reply via email to