Results 1 to 5 of 5

Thread: [RESOLVED] hiding element

  1. #1

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Resolved [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

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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

  3. #3
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    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";

  4. #4

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Resolved Re: hiding element

    Thanks both of you, it worked.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  5. #5
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    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
  •  



Click Here to Expand Forum to Full Width