jquery で div の高さを auto に設定し、その高さを再度計算しようとすると、結果として 0 が返されます。これはなぜですか?
$('#test').css('height','auto')
$('#test').height(); // 0
代わりにその高さを計算するにはどうすればよいですか?
編集
これは私が実行しているJavaScriptコードです:
function visitFix() {
$('.visit').find('.profileDetail').each(function () {
console.log($(this).height()); //24
$(this).css('height', 'auto');
console.log($(this).height()); // 0
});
}
DOM ツリーは次のようになります。
<td class="profileView">
<div class="profileContent">Purpose: </div>
<div class="profileDetail" style="height: auto;">Program Participant Volunteer Rejuvenation Participant General Visit </div>
</td>
出力は 24 で、次に 0 です。