When changing the height of elements with jQuery you will probably have cases when you need to set the height to be on “auto”, so the browser will automatically calculate it’s height.

This is easy to do, see the example:


How does the height function work? If the parameter specified is a number the function will apply a height of that amount of pixels. If the parameter is string it will work pretty much as defining it in CSS.
Possible values:

As you can see it will work with any css measurement type and with the keyword auto. If the string is not auto and does not have any measurement type (like ‘400′) it will use pixels (400px).
The width() function works the same as described above.