jQuery outerHeight() Method

The jQuery outerHeight() method returns the outer height of the selected element. The value of outer height includes the padding and border of the element.

It can also include the margin property by passing the boolean value as a parameter.

jQuery outerHeight() Method

Syntax of jQuery outerHeight() Method

The syntax of this method is given below:-

Return the height of an element
$(selector).outerHeight()
Sets the height of an element
$(selector).outerHeight(includeMargin)

Description of the Parameters

The description of the parameters is given below.

Parameter Name Description
selector You have to specify the element class, id, or tag name to select the elements and return or sets the outer height.
includeMargin It is the boolean value to include the margin with height for the selected element. If you specify true, it includes the margin with outer height. false indicates that the margin is not included with outer height.

jQuery outerHeight() Method Returns the Value of Outer Height

If you want to get the outer height for the selected element, you have to use the method as given below. It returns the outer height of the element if specified in the selected element.

The below example contains the button and the div element. The div element contains some width and height including the padding and margin.

Example

Test it Live

Output

You have to click the button given above to get the outer height in the alert box. The outer height includes the element height and padding but not the margin.

How to Include Margin with Outer Height

To get the margin with the outer height, you have to pass ‘true’ as the parameter of the method. See the example below contains the same elements as given above.

Example

Test it Live

Output

Click the button given above to get the outer height in the alert box including the margin. You will get different outer height values from the previous example value.

You may also like to read

I hope you like this tutorial on jQuery outerHeight() method. If you have any queries regarding the tutorial, please comment below.

References