Reputation: 6797
Will jQuery run the function passed in $(window).load(callback)
, when this listener added after the window.load
event?
Upvotes: 2
Views: 15613
Reputation: 41934
No, it won't: http://jsfiddle.net/WouterJ/zMEZA/
But a $(window).ready
event will: http://jsfiddle.net/WouterJ/zMEZA/1/
Upvotes: 7
Reputation: 227200
No, $(window).load(function(){})
is only called if it's bound before the event.
On the flip side, $(document).ready(function(){})
(and its shorthand $(function(){})
) will be triggered (immediately) if they are bound after the event.
Upvotes: 9