display:none 要素に対しては 0 を返すべきだと思います。しかし、少なくとも1.10.1ではそうではありません
<div id="a" style="display:none">
asdf
asdfasdf<br>
sadf
</div>
alert($('#a').outerHeight(true))
display:none 要素に対しては 0 を返すべきだと思います。しかし、少なくとも1.10.1ではそうではありません
<div id="a" style="display:none">
asdf
asdfasdf<br>
sadf
</div>
alert($('#a').outerHeight(true))
jQuery は、要素が画面に表示されているかどうかに関係なく、要素の高さを示します。
非表示の要素を無視する場合は、次を使用します。
$('#a').is(':visible') ? $('#a').outerHeight(true) : 0;
$.css から $.style、$.cssHooks から $.cssHooks.height.get を掘り下げると、原因がわかります。
function ( elem, computed, extra ) {
if ( computed ) {
// certain elements can have dimension info if we invisibly show them
// however, it must have a current display style that would benefit from this
return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
jQuery.swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra );
}) :
getWidthOrHeight( elem, name, extra );
}
}
スタイルを交換し、値をリッピングしてから、それを display:none に戻すようです。