问题
I'm trying to find out the outer height of a element (including padding) and it doesn't seem to work.
I always get 0. Is it because the element is hidden?
The element is contained inside a absolute-positioned element with "auto" height, but I don't think that should be a issue, because the element is relative...
回答1:
a hidden element has an outer height,
<div id="aaa" style="visibility:hidden">aaa</div>
<div id="bbb" style="visibility:hidden"></div>
alert($("#aaa").outerHeight());// returns 20
alert($("#bbb").outerHeight()); //returns 0
please add your html code for a more complete answer
回答2:
An element with hidden with a display: none;
does not register height or width, but an element with visibility: hidden;
does, but it also must be attached to the body
or one of its children elements.
来源:https://stackoverflow.com/questions/7131995/jquery-outerheight-doesnt-work-when-element-is-hidden