The html
Code: Select all
<div id="selfContain">
In the first two chapters, we reviewed the basics of writing proper (X)HTML and gave you
a general overview of CSS. You learned how to attach style sheets to your documents, but now
it’s time to put on your work clothes, head to the garage, and rip apart the engine to find out
exactly how the darn thing runs.
</div>
Code: Select all
function showHeight()
{
var theElement;
var theElementStyle;
theElement = document.getElementById('selfContain');
theElementStyle = theElement.style;
theHeight = theElementStyle.height;
if (theHeight == 'NULL')
{
alert('No height set');
}
else
{
alert('Something else');
}
}
Edit
I got it sorted, if you use 'height: auto' there's no problem. The finished code looks like this
Code: Select all
function increaseHeight()
{
theElement = document.getElementById('container'); // assign & define the element
theElementStyle = theElement.style; //
theElementStyle.height == 'auto' ? theElementStyle.height = '50px' : theElementStyle.height = 'auto'; // height adjustment
theElementStyle.overflowY == 'auto' ? theElementStyle.overflowY = 'scroll' : theElementStyle.overflowY = 'auto'; // overflow adjustment
}