2009-11-13 3 views
0

У меня есть div, я хочу получить высоту div.Как получить высоту div с помощью jquery в IE

$('.graph_container').css('height') 

и КСС

.graph_container { 
    width:100%; 
    float:left; 
    border:1px solid #CCCCCC; 
    margin-top:1em; 
    position:relative; 
} 

поскольку высота не упоминается, в IE он дает 'Auto'. Как я могу получить точную высоту.

Я ценю ваши предложения.

ответ

3
$('.graph_container').height() 

который возвращает число.

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>