如何获取由 jQuery 设置的 DIV 的高度?
$('.bar2').animate({'height':'58' + "%"},1500);
当我检查 chrome 中的元素时,我发现我的 DIV 高度设置为 58%
<div class="bar2" style="height: 58%; background-image: ......>
我试过这个:
var bar2 = $(".bar2").height(),
或 var bar2 = $(".bar2").css('height'),
但我总是得到 70px 的“最小高度”,而不是 jQuery 设置的高度
最佳答案
我想你会使用:
$(".bar2").outerHeight();
哪个是计算出来的高度或者
$(".bar2").innerHeight();
如果您不需要考虑 margin 和填充等等。
关于element.style 的 jQuery 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11230950/