Okay you could have a function that toggles the area, this one will completely remove the space from where the div was.
- Code: Select all
<script type="text/javascript">
function toggle(obj, lnk)
{
obj = document.getElementById(obj);
if (obj.style.display != 'block')
{
obj.style.display = 'block';
lnk.innerHTML = 'Close';
} else {
obj.style.display = 'none';
lnk.innerHTML = 'Open';
}
}
</script>
<a href="javascript:void()" onclick="toggle('cont', this)">Open</a>
<div id="cont" style="display:none;">
Hello Div COntent
</div>
It seems like your code is doing a lot more work than it has to.
Cheers