user
user

Reputation: 6797

jQuery (window).load after the page loaded?

Will jQuery run the function passed in $(window).load(callback), when this listener added after the window.load event?

Upvotes: 2

Views: 15613

Answers (2)

Wouter J
Wouter J

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

gen_Eric
gen_Eric

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

Related Questions