我有一个表格,当我将鼠标悬停在表格内的单元格上时,当前单元格和第一列会突出显示:
$('.price_cell').hover(function(){
$(this).css('background-color','#cce6ff');
$('td:first', $(this).parents('tr')).css({'background-color':'#0096E1','color':'#ffffff'});
},
function(){
$(this).css('background-color','#ffffff');
$('td:first', $(this).parents('tr')).css({'background-color':'#ffffff','color':'#002436'});
});
这很好用。然而,虽然我希望第一列单元格在用户将鼠标悬停在该行上的单元格上时改变颜色,但我不希望第一列单元格在悬停时改变颜色。
最佳答案
您也可以使用纯 css 来完成此操作。
table tr:hover { background-color: black; color:white;}
table tr:hover td:first-child { background-color:white; color:black }
关于jquery - 使用 JQuery 突出显示一行中的第一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5695475/