What is the major difference between $(window).width() vs $(document).width() in jQuery?
Whether window denotes the browser and document represents
Well, the
windowis the first thing that gets loaded into the browser. Thiswindowobject has the majority of the properties likelength,innerWidth,innerHeight,name, if it has been closed, its parents, and more.What about the document object then?
The
documentobject is your html document that will be loaded into the browser. Thedocumentactually gets loaded inside thewindowobject and has properties available to it like title, URL, cookie, etc. What does this really mean? That means if you want to access a property for thewindowit iswindow.property, if it isdocumentit iswindow.document.propertywhich is also available in short asdocument.property.
So in conclusion the document could be smaller than the window.
FROM: http://eligeske.com/jquery/what-is-the-difference-between-document-and-window-objects-2/