The height of the jQuery element. style

How to get jQuery DIV height?
$('.bar2').animate({'height':'58' + "%"},1500);

When I check the elements in chrome, I see that my div height is set to 58%

<div class="bar2" style="height: 58%; background-image: ......>

I tried this:

var bar2 = $(".bar2").height(), or var bar2 = $(".bar2").css('height'),

but I always get my "minimum height" which is 70 pixels, not the height set by jQuery

+5
source share
2 answers

HTML:

<div style="width: 200px; height: 200px; background-color: blue;">
    <div class="bar2" style="min-height: 70px; width: 100px; background-color: red;">foo</div>
</div>

JS:

jQuery('.bar2').animate({'height':'58' + "%"}, 1500, function() {
    alert($(".bar2").css('height'))
});

Here's a live example - http://jsfiddle.net/ANbrq/1/

You can only get different heights when it really changed. If you try to get it right after asking it to resize, you will get the initial height.

+2
source

I think you would use:

$(".bar2").outerHeight();

What is the calculated height or

$(".bar2").innerHeight();

If you do not need to take margin accounts and indents, and what - no.

+3
source

All Articles