height() method in jQuery

height() in jQuery

This method is used to get the current height for the first element in the set of matched elements.

Syntax 1

$(selector).height()

Syntax 2

$(selector).height(value)

  • value - An integer representing the number of pixels
Syntax 3

$(selector).height(function(index,currentHeight))

  • index - index position of the element in the set.
  • currentHeight - old height of the element.

Example 1 - get

Try Yourself

Example 2 - set

Try Yourself

Example 3 - with function

Try Yourself

Example 4 - Difference between height() and innerHeight()

Try Yourself

Example 5 - Difference between height() and outerHeight()

Try Yourself