Код:
<script>
var interval = 10;
var action = '';
function show( divId, maxHeight )
{
var div = document.getElementById( divId );
if ( null == div || undefined == div )
{
return false;
}
if ( action == 'showing' && parseInt(div.style.height) < maxHeight )
{
var height = parseInt(div.style.height);
div.style.height = height + 10 + 'px';
setTimeout( 'show( “' + divId + '”, ' + maxHeight + ' )', interval );
}
else
{
( action == 'showing' ) ? action = '' : null;
}
}
function slideDownDiv( divId, height )
{
if ( action == '' )
{
action = 'showing';
show( divId, height );
}
}
function hide( divId, minHeight )
{
var div = document.getElementById( divId );
if ( null == div || undefined == div )
{
return false;
}
if ( action == 'hiding' && parseInt(div.style.height) > minHeight )
{
height = parseInt(div.style.height);
div.style.height = parseInt(height - 10) + 'px';
setTimeout( 'hide( “' + divId + '”, ' + minHeight + ' )', interval );
}
else
{
( action == 'hiding' ) ? action = '' : null;
}
}
function slideUpDiv( divId, height )
{
if ( action == '' )
{
action = 'hiding';
hide( divId, height );
}
}
</script>
<div style=”width: 500px; height: 500px; background: #ffeeee”>
<div style=”width: 300px; height: 300px; background: #eeffee; overflow: hidden” id=”showingDiv”>
<span><!– без него (span) ие будет выделываться –>
qweqwe<br>
asdasdasd<br>
asdasdasd<br>
asdasdasd<br>
asdasdasd<br>
asdasdasd<br>
asdasdasd<br>
asdasdasd<br>
zxczxczxc
</span>
</div>
</div>
<div>
<input type=”button” onclick=”slideDownDiv( 'showingDiv', 300 )” value=”show div”>
<input type=”button” onclick=”slideUpDiv( 'showingDiv', 0 )” value=”hide div”>
</div>