View Single Post
  #2 (permalink)  
Old Sep 29th, 2007, 23:55
Rakuli's Avatar
Rakuli Rakuli is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show&Hide Div Box

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