Results 1 to 3 of 3

Thread: Hide on Mouseover

  1. #1
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Hide on Mouseover

    How do I get the red box to disappear once the user mouses over the text, then reappear when the user moves the mouse off of the text?

    Code:
    <p align="center"><a href=null>Hide Cell</a></p>
    
    <table id="tableNode" align="center">
        <tbody>
            <tr><td colspan="30" rowspan="30" height="30" 
    
    bgcolor="red"></td></tr>
       <tbody>
    </table>
    Last edited by jscheuer1; 07-31-2008 at 03:12 PM. Reason: format code properly

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well it depends, given that simple markup (corrected slightly, to at least be valid in quirksmode - means on a page with no DOCTYPE), this would be about the easiest:

    Code:
    <p align="center"><a href="#" 
    onmouseover="document.getElementById('tableNode').style.display='none';" 
    onmouseout="document.getElementById('tableNode').style.display='';" 
    onclick="return false;">Hide Cell</a></p>
    
    <table id="tableNode" align="center">
        <tbody>
            <tr><td height="30" width="30" bgcolor="red"></td></tr>
       </tbody>
    </table>
    And that will remove it from the flow of the page. If you don't want it removed from the flow of the page, just to become invisible:

    Code:
    <p align="center"><a href="#" 
    onmouseover="document.getElementById('tableNode').style.visibility='hidden';" 
    onmouseout="document.getElementById('tableNode').style.visibility='';" 
    onclick="return false;">Hide Cell</a></p>
    
    <table id="tableNode" align="center">
        <tbody>
            <tr><td height="30" width="30" bgcolor="red"></td></tr>
       </tbody>
    </table>
    If you want to affect only the table cell itself, you would need to give it an id or get it as a part of the table's rows[0] cell's collection's 0 member. However you get it, at that point setting its display to none could throw off other rows/cells in the table if there were more than one row and/or cell. Using the visibility property wouldn't have this problem.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Jus S (07-31-2008)

  4. #3
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1,

    Thanks for the options. Worked great.

    Jus S

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •