AskLo
AskLo

Reputation: 29

Get real Height of div (Jquery)

I want to know the real height of a div.

if i ask for $var.height() he just tell me the fix css height.

How can I get the real height of the div and not the fixed css height.

Upvotes: 2

Views: 10616

Answers (2)

Ganesh Putta
Ganesh Putta

Reputation: 2681

Have you tried outerHeight(), May be this will help you, try this

$(document).ready(function() {
  $("button").click(function() {
    alert("Outer height of div: " + $("div").outerHeight());
  });
});
div {
  height: 100px;
  width: 300px;
  padding: 10px;
  margin: 3px;
  border: 1px solid blue;
  background-color: lightblue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<div></div><br>

<button>Display the outer height of div</button>
<p>outerHeight() - returns the outer height of an element (includes padding and border).</p>

Upvotes: 6

Suresh Atta
Suresh Atta

Reputation: 122026

jquery have outerHeight() function.

http://api.jquery.com/outerheight/

Get the current computed outer height (including padding, border, and optionally margin)

Upvotes: 3

Related Questions