How do I remove the height style from a DIV using jQuery?

Zack Peterson picture Zack Peterson · Apr 29, 2009 · Viewed 101.2k times · Source

By default, a DIV's height is determined by its contents.

But, I override that and explicitly set a height with jQuery:

$('div#someDiv').height(someNumberOfPixels);

How can I reverse that? I want to remove the height style and to make it go back to it's automatic/natural height?

Answer

user268828 picture user268828 · Feb 13, 2010

to remove the height:

$('div#someDiv').css('height', '');
$('div#someDiv').css('height', null);

like John pointed out, set height to auto:

$('div#someDiv').css('height', 'auto');

(checked with jQuery 1.4)