jQuery outerHeight()Methods

jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Examples

Return the outer height of a <div> element:

$("button").click(function(){ alert($("div").outerHeight()); });

Try it Yourself »

Definition and Usage

The outerHeight() method returnsthe first matched element'souter height.

As shown in the image below, this method includes padding and border.

Tip:To include margin, use outerHeight(true).

jQuery Dimensions


Related methods:

  • width()- Set or return the width of an element
  • height()- Set or return the height of an element
  • innerWidth()- Return the width of an element (includes padding)
  • innerHeight()- Return the height of an element (includes padding)
  • outerWidth()- Return the width of an element (includes padding and border)

Syntax

$(selector).outerHeight(includeMargin)

Parameter Description
includeMargin Optional. Boolean value specifying whether to include margin.
  • false- By default, does not include margin.
  • true- Includes margin.


实例

More Examples

Include margin
Specifies whether to include margin.

Display dimensions using related methods
How to use width(), height(), innerHeight(), innerWidth(), outerWidth() and outerHeight().


jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Other extensions