javascript - Call a function on DOM ready from outside <head>? -


in jquery can wrap code in $(function() { ... }); , have fire when dom ready, if want put in middle of page somewhere? isn't possible dom ready event fire before processes chunk of code , it'll missed? there way guarantee it'll fired?

you can place <script>..</script> block anywhere in code:

  • if use .ready() (or equivalent syntax) execute code when dom loaded, executed when whole page loaded, no matter placed ready() handler.

  • if put code within <script> tags, executed whenever parser reaches point of code.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -