我有一个div,我想得到div的高度。
$('.graph_container').css('height')
和css是
.graph_container {
width:100%;
float:left;
border:1px solid #CCCCCC;
margin-top:1em;
position:relative;
}
因为没有提到高度,所以在IE中它给出'auto'。我怎样才能达到高度。
感谢您的建议。
答案 0 :(得分:3)
$('.graph_container').height()
返回一个数字。
答案 1 :(得分:0)
要计算任何元素或窗口或文档的高度,我们可以使用" height()" jQuery的方法。
$(document).ready(function(){
$("p").append($("p").height()+" px");
$("div.divContainer").append($("div.divContainer").height()+" px");
$("div.document").append($(document).height()+" px");
$("div.window").append($(window).height()+" px");
});
<div class="document">Height of this document is: </div>
<div class="window">Height of this window is: </div>
<div class="divContainer">Height of this div container is: </div>
<p>Height of this paragraph is: </p>