views:

9

answers:

1

Hi,

I have got an HTML Element with content in it and height: "auto";

No I try to get its height with jQuery:

height = $('#inhalt').css("height").replace("px", "");

In Safari and Firefox it works and gives me a number depending on the amount of text in the element. IE however returns "auto" which is right but obviously makes it hard to calculate...

Have you got any type of advice for me? Thank you all, Jag Älskar

+1  A: 

Try height():

Get the current computed height for the first element in the set of matched elements.

e.g. like so:

height = $('#inhalt').height();

Works for me in IE6, 7 and 8. JSFiddle

Update: That said, .css("height") works for me in all versions of IE as well. JSFiddle

Pekka