html - 链接整个表行?

标签 html css

<分区>

我知道可以使用 CSS 链接整个表格单元格。

.tableClass td a{
   display: block;
}

有没有办法将链接应用于整个表格行?

最佳答案

我同意 Matti .使用一些简单的 javascript 很容易做到。一个快速的 jquery 示例是这样的:

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


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

然后在你的 CSS 中

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

关于html - 链接整个表行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4904938/

相关文章:

javascript - 将 PNG 分层(HTML5、JS)

php - 无法在表中显示逗号分隔值

html - caption(table) 和 legend(fieldset) 是唯一的 html first descendant 限制吗?

javascript - 使用 jquery 将 id 分配给现有 div

javascript - Bootstrap 管理模板响应菜单不起作用

html - 从 flex 显示中消除横向滚动条

javascript - 分层数据上基于TR id的TD条件求和

html - Disqus:如何自定义计数器

javascript - JQuery 滑动开关 :visible conditional

javascript - 可视化调色板查询javascript circosjs