【发布时间】:2011-12-31 05:29:17
【问题描述】:
我有 4 个名为 col1、col2、col3、col4 的列表。列具有不同的颜色。 col1 有工具提示链接。当光标指向链接时,将显示工具提示以及要更改的行的背景图像。整个表格只有一张背景图片。
我尝试使用以下代码,但在 Chrome 和 Safari 中,它为所有 4 个 cols 显示相同的颜色(第一个 col 的颜色)。
$(function() {
$('td:first-child a').hover(function() {
$(this).closest('table.benefitstable tbody tr').toggleClass("highlight");
});
});
.benefitstable tbody tr.highlight {
background:url(../images/tablerowhover.jpg) 0 0 no-repeat;
}
它几乎等同于没有使用以下标签的jQuery:
.benefitstable tbody tr:hover {
background:url(../images/tablerowhover.jpg) 0 0 no-repeat;
}
有什么帮助吗?
【问题讨论】:
-
Twitter bootstrap zebra table 实现了这个,可能想看看twitter.github.com/bootstrap/#tables
-
对 twitter bootstrap 不感兴趣,因为它为许多元素指定了 18px 的边距/填充。