jQuery Tutorial Tutorials - jQuery .height() method

jQuery .height() method

The .height() method in jQuery is used to get/set the height of the matched element.

jQuery .height() method Syntax

.height()
.height(value)
.height(function)
Parameter Type Description
value String,Number the height value to set
funtion(index, oldHeight) Function a function returning the height to set.
index is the position of the element in the set.(based on 0)
oldHeight is the old height.

.height()

Get the height of the first matched element.(If the element is not visible, the height would be 0 )

example

Get the height of the first paragraph

$("p").height();

Try now

.height(value)

example

Set the height of each p to 30px

$("p").height(30);

Try now

.height(function)

Set the element 10px higher than the previous.

$("p").height(function(index,oldValue){
    return 10*index + oldValue;
});

Try now

Date:2019-08-20 15:26:35 From:www.Lautturi.com author:Lautturi