Easy Tutorial
❮ Misc Param Eff Fadetoggle ❯

jQuery height() Method

jQuery HTML/CSS Methods

Example

Return the height of a <div> element:

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

Definition and Usage

The height() method sets or returns the height of the selected elements.

When used to return the height,

When used to set the height, it sets the height of all matched elements.

As shown in the image below, this method does not include padding, border, or margin.


Related Methods:


Syntax

Return the height:

Set the height:

Set the height using a function:

Parameter Description
value Required when setting the height. Specifies the height of the element in units like px, em, pt, etc. <br>The default unit is px.
function (index, currentheight) Optional. A function that returns the new height of the selected element. index - Returns the index position of the element in the set. <br>currentheight - Returns the current height of the selected element.

More Examples

Set the height of an element

Increase the height using a function

Return the height of the document and window elements

Display dimensions using related methods


jQuery HTML/CSS Methods

❮ Misc Param Eff Fadetoggle ❯