我正在开发一个拥有大型表格的网站(18行x11列)。为了方便查看表格的人,我使用以下代码使TR悬停时呈现不同的颜色:
.responsive tr:hover {
background-color: red;
}
但我希望用同样的方法来处理列。但是,如果我使用
.responsive td:hover {background-color: blue;}
,它只会悬停在单个TD上,而不是整个列。至少,每个TD都有类名col1
、col2
等。如何在悬停在TD上时更改CSS属性?如果这是可能的,当我悬停在
col1
TD上时,我可以更改类col1
的background-color
。有任何想法吗?
colspan
可能会有些困难,因此此解决方案不尝试。 - John Dvorak.col1,.col2 ...
来附加.colHover
类。然后一旦计算出colspans,就很容易定位它们。 - John Dvorak$('td:nth-child('+($(this).index()+1)+')').addClass('colHover');
- euDennis