|
-
Feb 12th, 2011, 03:53 AM
#1
Thread Starter
Lively Member
[RESOLVED] hiding element
I have a table enclosed in <div> tag. With a click of button, the hidden attribute toggles between hidden and visible.
Code:
document.getElementById(a).style.visibility = "hidden";
Code:
document.getElementById(a).style.visibility = "visible";
Hiding and displaying works well, but when the element is hidden, there is still large blank area that is visible. By hiding the element, I want to gain that space too.
Using height property is not helping.
Code:
document.getElementById(a).style.height = 0+"px";
Is there any way I can gain that space when an element is hidden?
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
-
Feb 12th, 2011, 03:56 AM
#2
Re: hiding element
Change the display to none and back to block.
Also read about the differences of visibility and display from CSS Property Index
-
Feb 12th, 2011, 07:47 AM
#3
Fanatic Member
Re: hiding element
"display" is set to "block" by default which means no matter what the "visibility" is set to, it will always be "display:block;", which means otherwise it will always be there, so you need to change it like Merri says.
Code:
document.getElementById(a).style.display = "none";
Code:
document.getElementById(a).style.display = "block";
-
Feb 12th, 2011, 08:34 AM
#4
Thread Starter
Lively Member
Re: hiding element
Thanks both of you, it worked.
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
-
Feb 12th, 2011, 09:27 AM
#5
Fanatic Member
Re: hiding element
sridharao, if you do not mark the threads as resolved, people wont see that you have gotten the help needed to complete what you're attempting to do, so please mark your threads as resolved when your question(s) have been answered properly/correctly.
if you do not know how, then visit this link: http://www.vbforums.com/showthread.php?t=551337
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|