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 placedready()
handler.if put code within
<script>
tags, executed whenever parser reaches point of code.
Comments
Post a Comment