我需要获取 div 的高度。我无法在 css 中设置高度,因为内容可能会发生变化(这取决于其中的内容)。 我试过:
var buttonsHeight = $(".buttonsContainer").height();
和
var buttonsHeight = $(".buttonsContainer").outerHeight();
和
var buttonsHeight = $(".buttonsContainer").innerHeight();
在每种情况下 buttonsHeight
都是 null
。
CSS:
.buttonsContainer{
padding:31px 16px 0;
position:fixed;
}
fiddle : http://jsfiddle.net/U7Kck/3/
如果你更换 填充:20px 0;高度:40px 然后 buttonsContainer 看起来不错......
最佳答案
var buttonsHeight = $(".buttonsContainer")[0].clientHeight
关于jquery - 如何测量没有高度的div的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19093768/