$(document).ready(function(){
//your code here
});
$(function(){
//your code here
});
To wait until the page is finish loaded before execute particular code, you can use any one of jquery codes above. The both codes above are 99% the same. They are just make sure the codes of the pages are finish loaded, but they can't make sure the images on the pages are finish loaded. To detect images, you need to use the codes below :
window.onload = function(){
//your code here
};
$(window).load(function(){
//your code here
});
The 1st code above window.onload is normal javascript which is bad idea because it prevents you from setting onload from anything else or will erase any other "onload". To avoid overwriting the hooks that are already attached to the window.onload, attach your function with jQuery: $(window).load(function(){});
Posted by Zac1987 on
05 June, 2011
1 Comment
Thanks for finally talking about > "window.onload = function() VS $(document).ready (function()" < Loved it!
My weblog: Testo XL muscle
Posted on 10:36 PM, November 30, 2014