ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What are the difference between jquery $(windows).load() and $(document).ready()?

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2015/10/10
Magdy Hassan
من قبل Magdy Hassan , Senior Web Developer , Massive Solutions

$(document).ready() executes when HTML-Document is loaded and DOM is ready

$(windows).load() executes when complete page is fully loaded, including all frames, objects and images

مستخدم محذوف‎
من قبل مستخدم محذوف‎

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, 

when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds functionality to the elements in the page doesn't have to wait for all content to load.

Ibtisam Ul Haq
من قبل Ibtisam Ul Haq , Full Stack Developer

$(windos).load() will wait to complete all http request including rending of images/videos etc where as $(docment).ready() will wait till the document/html page render on in other word when dom is ready.

Suresh kumar
من قبل Suresh kumar , Sr Web Developer , Clerisy Solution Private limited

Yes, you are right rehan . $(document).ready() we use when you want to fire event on dom load and window loaf is used when all content get loaded.

Rehan Farooq
من قبل Rehan Farooq , WEB DEVELOPER/DIGITAL MARKETING EXPERT , Upwork

The difference are:$(document).ready(function() { is jQuery event that is fired when DOM is loaded, so it’s fired when the document structure is ready.$(window).load() event is fired after whole content is loaded.

المزيد من الأسئلة المماثلة