What is the difference between
$(window).load(function () {});
And
$(window).ready(function () {});
What is the difference between window load and window ready?
What is the difference between
$(window).load(function () {});
And
$(window).ready(function () {});
What is the difference between window load and window ready?
window.ready occurs when all of the DOM has been loaded but images may not have been loaded
window load occurs after all images have finished loading
ready event happens first so most code can be placed her
document.ready
is a jQuery event, it runs when the DOM is ready
window.onload
fires later when images and such are loaded
Example Script
$(document).ready(function() {
// executes when HTML-Document is loaded and DOM is ready
alert("document is ready");
});
$(window).load(function() {
// executes when complete page is fully loaded, including all frames, objects and images
alert("window is loaded");
});
Refer