Reputation: 41595
I am trying to the the height
attribute of an absolute positioned DIV with a non predefined height attribute.
The height of the div
depends on its dynamic content.
I've seen that .height()
function of jQuery doesn't return the correct height of an absolute positioned div
.
$(this).height() //not working well
Is there any way to get its height?
Thanks.
Upvotes: 4
Views: 13364
Reputation: 128
You need to have some content inside the div or at least define some minimum height in order to get the css height property—which is otherwise undefined.
The .height()
gets the computed height for the element and thus needs some predefining.
Alternatives are the .innerHeight()
and .outerHeight()
methods. They might work better if you are working with the default content-box style.
Upvotes: 1