Web Analytics Made Easy -
StatCounter Table Rows and onMouseOver - CodingForum

Announcement

Collapse
No announcement yet.

Table Rows and onMouseOver

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Table Rows and onMouseOver

    I have a table that has X rows and 5 columns and I am looking to change the bg colour of the whole row when the mouse goes over a cell.

    At the moment I can change the colour of each cell individually with:

    <td onMouseOver="this.style.backgroundColor='#d7d7d7';">

    and I have tried it with <tr onMouseOver="this.style.backgroundColor='#d7d7d7';"> but this does not seem to work.

    Is there a way?

    Thanks!

  • #2
    In your css,
    td:hover {
    background-color: #000000;
    }

    I'm not sure if the same can be done with tr though. And this won't work in Internet Explorer.
    I lost my signature, have you seen it?
    I have the power to erase you...

    Comment


    • #3
      http://www.xs4all.nl/~peterned/csshover.html

      Grab the .htc file from there.

      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
      
      "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <title>tr hover</title>
      <style type="text/css">
      body {
      behavior:url("csshover.htc");
      }
      table {
      height: 100px;
      width: 100%;
      border: 1px solid green;
      }
      tr {
      background-color: #ff6;
      }
      tr:hover {
      background-color: #ccc;
      }
      </style>
      </head>
      <body>
      <table>
      <tr><td></td><td></td><td></td></tr>
      </table>
      </body>
      </html>
      works on IE6 for me
      Stop making things so hard on yourself.
      i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

      Comment


      • #4
        I read somewhere that IE only supports :hover in links. Might be wrong thogh.
        I lost my signature, have you seen it?
        I have the power to erase you...

        Comment


        • #5
          I read somewhere that IE only supports :hover in links. Might be wrong thogh.
          You're right, the link harbingerOTV posted is for a workaround to make :hover work on any element.
          Computer, kill Flanders... Did I hear my name? My ears are burning...
          Good start. Now finish the job.

          Comment


          • #6
            Excellent, thanks a lot guys!

            Comment

            Working...
            X