Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add functions to $(window).load()?

Just curious if there's an easy way to add functions to the $(window).load() event before it has fired. For example, if you call $(window).load() twice in the beginning of the page, only the function of the second call will execute onload.

Is there some sort of tool built into jQuery for adding to the onload event instead of replacing it? If so, how about for the $(document).ready() call?

like image 531
trusktr Avatar asked Jan 19 '23 13:01

trusktr


1 Answers

They actually do stack in the order specified. Here's an example : http://jsfiddle.net/73D9Z/

I've used window.ready()

$(window).ready(function(){
    alert('window ready 1');
});

$(window).ready(function(){
    alert('window ready 2');
});

$(document).ready(function(){
    alert('document ready 1');
});

$(document).ready(function(){
    alert('document ready 2');
});
like image 117
JohnP Avatar answered Jan 29 '23 05:01

JohnP