jQuery .height will return you the height of the element. It does not require a CSS definition because it determines the calculated height.
Demo
You can use .height() , .innerHeight() or outerHeight() based on what you need.

.height() - returns the height of the element, excluding indents, borders and fields.
.innerHeight() - returns the height of the element, including padding, but excludes border and margin.
.outerHeight() - returns the height of the div, including the border, but excludes the margin.
.outerHeight(true) - returns the height of the div, including the margin.
Check out the code snippet below for a live demo. :)
$(function() { var $heightTest = $('#heightTest'); $heightTest.html('Div style set as "height: 180px; padding: 10px; margin: 10px; border: 2px solid blue;"') .append('<p>Height (.height() returns) : ' + $heightTest.height() + ' [Just Height]</p>') .append('<p>Inner Height (.innerHeight() returns): ' + $heightTest.innerHeight() + ' [Height + Padding (without border)]</p>') .append('<p>Outer Height (.outerHeight() returns): ' + $heightTest.outerHeight() + ' [Height + Padding + Border]</p>') .append('<p>Outer Height (.outerHeight(true) returns): ' + $heightTest.outerHeight(true) + ' [Height + Padding + Border + Margin]</p>') });
div { font-size: 0.9em; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="heightTest" style="height: 150px; padding: 10px; margin: 10px; border: 2px solid blue; overflow: hidden; "> </div>
Selvakumar Arumugam Mar 06 '12 at 22:00 2012-03-06 22:00
source share