Jquery obtains the height and width Function Analysis of window, document, and DOM elements.

Source: Internet
Author: User

(This article reproduced: http://csumissu.iteye.com/blog/1118790)

Jquery (window). Height () indicates the size of the currently visible area, while jquery (document). Height () indicates the height of the entire document.

Note that jquery (window). Height () changes as the browser window size changes (for example, after the window is maximized or enlarged), but jquery (document). Height () does not change.

The following shows the jquery source code for obtaining the height or width function.

// Create jquery. height (size) jquery. width (size) // call the each method to create two similar functions jquery. each (["height", "width"], function (I, name) {var type = Name. tolowercase (); jquery. FN [type] = function (size) {var ELEM = This [0]; If (! ELEM) {return size = NULL? Null: This;} If (jquery. isfunction (size) {return this. each (function (I) {var self = jquery (this); self [type] (size. call (this, I, self [type] ();}) ;}// obtain the height or width of the window object ($ (window ). width () is actually the height or width of the currently visible area if (jquery. iswindow (ELEM) {// everyone else use document.doc umentelement or document. body depending on quirks vs standards mode // 3rd condition allows Nokia support, As it supports the docelem prop but not css1compat // The above English meaning is dependent on the quirks or standards document mode to use // document.doc umentelement (actually 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.