views:

890

answers:

5

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?

A: 
$('div#someDiv').attr("height","");
Frank Rosario
+1  A: 

maybe something like

$('div#someDiv').css("height", "auto");
John Boker
+1  A: 
$('div#someDiv').removeAttr("height");
rahul
A: 

To keep the way you did it before, just try

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

Gushiken
-1 this returns the current height of someDiv, it won't set it
Brandon Montgomery
+2  A: 

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)

I can confirm this works (jQuery 1.4.2 at least).
Josh K