#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    120
    Rep Power
    12

    CSS table color link change


    I am wondering what the code is for having the hover property of a link change the background color of the table?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    Here is one way

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript">
    function changeBG(el,color)
    {
    document.getElementById(el).style.backgroundColor = color;
    }
    </script>
    </head>
    
    <body>
    <p><a href="#" onmouseover="changeBG('mytable','#ff0000')">Click ME</a></p>
    <table id="mytable" width="300" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    120
    Rep Power
    12

    One thing


    The only problem with that is that when I roll out it still keeps the background color changed.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    You didn't say that you wanted it to change back.

    onmouseout="...."

IMN logo majestic logo threadwatch logo seochat tools logo