jQuery height() Method
jQuery height() method sets or returns the height of selected elements.
The height() method is useful when an element's height needs to be used in a mathematical calculation.
The height() method is also able to find the height of the window and the document.
Syntax
Here is a syntax for height() method that return the height
$(selector).height();
Set the height
$(selector).height( value );
Parameter | Type | Description |
---|---|---|
value | String | Optional. Specifies the height in px, em, pt, etc. Default measurement is px |
Example: Get Height
$(document).ready(function(){
$("button").click(function(){
alert($("p").height());
});
});
Example: Set Height
$(document).ready(function(){
$("button").click(function(){
$("p").height("100px");
});
});