I want to know the real height of the DOM element. My case is something like this. My example has not CSS, only a default browser CSS (Firefox), you can test it:
<div class="myClass">
<p>XXX</p>
<p>YYY</p>
<p>ZZZ</p>
</div>
<div class="myClass2">
UUU
</div>
Results:
jQuery(".myClass").height() ------> 89px
jQuery(".myClass").innerHeight() ------> 89px
jQuery(".myClass").innerHeight(true) ------> 89px
jQuery(".myClass").outerHeight() ------> 89px
jQuery(".myClass").outerHeight(true) ------> 89px
But the div.myClass has more height. The problem is with the elements that have margin. I know that I can execute something like this:
jQuery(".myClass").outerHeight(true)
But this only works if this element has the margin, in my case the margin has the children elements (the p
tags). You can test it, UUU
is moved downwardly because the margin of <p>ZZZ</p>
is there some way to know the real height?? or the real margin??
You can see in jsfiddle. This example has css because jsfiddle has css
I have fear, if I have this rule every works:
div.myClass {
border: 1px solid red;
}
Thanks,