Jquery obtains the element height.

Source: Internet
Author: User

. Height ()

-Obtain the current calculated height value of the first element in the matched element set or set the height value of each matching element.

The difference between -.css ('height') and. Height () is that the latter returns a value without a unit. The former returns a string with a complete unit. The. Height () method is recommended when the height of an element requires mathematical calculation.

-This method can also calculate the height of the window and document.

$ (Window). Height (); // returns height of browser viewport
$ (Document). Height (); // returns height of HTML document

Note: When the display: block is absolutely located and given, although the style and script labels are used. width () or height () will also report a value. We strongly recommend that you do not call these methods in these labels. This is a bad practice and the results prove unreliable.

. Innerheight ()

-Obtain the current calculated height value of the first element for the matched element set, including padding, but not border.

-This method returns the height of the element, including the top and bottom padding, in pixels.

-This method is not applicable to window and document objects and can be replaced by. Height.

. Outerheight ()

-Obtain the current calculation height of the first element in the Element Set, including padding, border, and selective margin. Returns an integer (excluding "PX"), or returns NULL if this method is called when an empty set is closed.

-. Outerheight ([includemargin]): Include is a Boolean value, indicating whether to include the margin value of the element during calculation.

-This method is not applicable to window and document objects and can be replaced by. Height.

Reference: http://www.css88.com/jqapi-1.9/category/dimensions/

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.