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

Viewed 108687

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?

9 Answers

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)

maybe something like

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

To reset the height of the div, just try

$("#someDiv").height('auto');

$('div#someDiv').removeAttr("height");
Related