Как получить высоту div, используя jquery в IE - PullRequest
0 голосов
/ 13 ноября 2009

У меня есть div, я хочу получить высоту div.

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

и css

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

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

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

Ответы [ 2 ]

3 голосов
/ 13 ноября 2009
$('.graph_container').height() 

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

0 голосов
/ 24 декабря 2012

Чтобы вычислить высоту любого элемента, окна или документа, мы можем использовать метод jQuery "height ()".

$(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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...