santa santa - 2 months ago 8
CSS Question

Link entire table row?

I know it is possible to link an entire table cell with CSS.

.tableClass td a{
display: block;
}


Is there a way to apply a link to an entire table row?

Answer

I agree with Matti. Would be easy to do with some simple javascript. A quick jquery example would be something like this:

<tr>
  <td><a href="http://www.example.com/">example</a></td>
  <td>another cell</td>
  <td>one more</td>
</tr>

and

$('tr').click( function() {
    window.location = $(this).find('a').attr('href');
}).hover( function() {
    $(this).toggleClass('hover');
});

then in your CSS

tr.hover {
   cursor: pointer;
   /* whatever other hover styles you want */
}