views:

984

answers:

2

This works in Firefox/Safari but not on IE

var h = parseInt($('#elementWhichHeightCanChange').css('height'));
alert(h);

on IE it returns NaN. Anyone know how to get div height depending on its content on IE?

I want to resize this popup window to fit the content, which currently works only on Firefox.

Thank you in advance.

+3  A: 

I have tried this, but it might work.

var h = $('#elementWhichHeightCanChange').height();
alert(h);

Use the height function or outerHeight instead of css height. You also won't need the parseInt() because this will return an integer, unlike css height.

Darryl Hein
+2  A: 

Try this

var h = $('#elementWhichHeightCanChange').outerHeight();
alert(h);

This will include paddings and borders - things you probably want to take into account.

alex