In this article, we will discuss what is the difference between document.ready and window.load in Jquery.
$(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");
});
So if we Use both $(document).ready and as well as $(window).load in a page then First $(document).ready will load and after that $(window).load will load.
So based on the requirement of the page if we want to load anything after page is fully loaded then at that time we should use $(window).load otherwise will use $(document).ready.
0 comments:
Post a Comment