On Tue, Dec 15, 2009 at 8:46 PM, brian <zijn.digi...@gmail.com> wrote:
> And, if you'd like callit() to be run only when the document is fully > loaded, just wrap the call in another $(document).ready() block: > > > <script type="text/javascript"> > $(document).ready(function() { > // whatever stuff needs to occur when the doc is loaded > }); > > // will be defined immediately > function callit() { > alert("Hello world!"); > } > </script> > <script type="text/javascript"> > $(document).ready(function() { > // will be run when doc is loaded > callit(); > }); > </script> > No need to add another block. As you pointed out earlier, the document ready won't run until later. By the time it does, the callit function will have been defined: <script type="text/javascript"> $(document).ready(function() { // will be run when doc is loaded callit(); }); // will be defined immediately function callit() { alert("Hello world!"); } </script> - Richard