Code has been added to clipboard!

jQuery .outerHeight(): Learn to Get the Outer Height of an Element

Reading time 1 min
Published Jan 19, 2018
Updated Sep 27, 2019

jQuery outerHeight: Main Tips

  • The .outerHeight() jQuery method returns the outer height of the first matched element.
  • By including relevant parameters, use jQuery .outerHeight() to set the outer height.
  • To learn more about jQuery height and width methods, read this tutorial.

Understanding and Using .outerHeight

By using .outerHeight(), you can make jQuery get element height including padding and border. Use the method to set CSS outer height for all matched elements as well.

Note: you can also specify whether you want the outer height to include margin.

The example below shows both possible functionalities of the jQuery .outerHeight(). After you click the button, the height of the element is displayed in an alert. Close it to see the element height change:

Example
$("button").click(() => {
    alert($("p").outerHeight());
});

$("button").click(() => {
    $("p").outerHeight(40);
});

To make jQuery get element height, follow this syntax:

$(selector).outerHeight(margin);

The optional parameter margin defines whether the outer height includes the margin. It has a boolean value (false by default).

To set the outer height, the syntax is as follows:

$(selector).outerHeight(newHeight);

You may use a string, a number, or a function returning the value needed to specify the newHeight.

Learn jQuery
Introduction
Selectors
Events
Event Methods
Download
Callback
Chaining
Get and Set
Add Element
Remove Element
Traverse
Parent
Children
Sibling Traverse
Filtering
jQuery AJAX
Effects
Show and Hide
Fade Effect
Slide Effect
Animate Effect
Manipulate CSS
Width and Height
.addClass()
.after()
.animate()
.append()
.appendTo()
.attr()
.before()
.bind() (deprecated)
.blur()
.change()
.click()
.clone()
.css()
.dblclick()
.delay()
.delegate() and .undelegate() (deprecated)
.detach()
.empty()
.end()
.error() (deprecated)
.fadeIn()
.fadeOut()
.fadeTo()
.fadeToggle()
.finish()
.focus()
.focusIn()
.focusOut()
.hasClass()
.height()
.hide()
.hover()
.html()
.innerHeight()
.innerWidth()
.insertAfter()
.insertBefore()
.keypress()
.keyup()
.live() and .die() (deprecated)
.load() (deprecated)
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseout()
.mouseover()
.mouseup()
.off()
.offset()
.offsetParent()
.on()
.one()
.outerHeight()
.outerWidth()
.position()
.prepend()
.prependTo()
.prop()
.proxy()
.queue()
.ready()
.remove()
.removeAttr()
.removeClass()
.removeProp()
.replaceAll()
.replaceWith()
.resize()
.scroll()
.scrollLeft()
.scrollTop()
.show()
.slideDown()
.slideToggle()
.slideUp()
.stop()
.submit()
.text()
.toggle()
.toggleClass()
.trigger()
.triggerHandler()
.unbind() (deprecated)
.unload() (deprecated)
.unwrap()
.val()
.width()
.wrap()
Event Properties
event.currentTarget
event.preventDefault()
event.relatedTarget
event.stopImmediatePropagation()
event.stopPropagation()
event.target
event.timeStamp
event.type
event.which
jQuery .find()
jQuery .keydown()
jQuery.noConflict()
pageY and pageX