【发布时间】:2013-10-18 03:20:39
【问题描述】:
我有以下代码:
$('table tr:not(:first-child)').mouseover(function() {
$(this).removeClass('hovered_error');
$(this).addClass('hovered');
}).mouseout(function() {
$(this).removeClass('hovered');
});
这很好用 - 但是,有没有办法让我不突出显示某些表格行,例如第 11 行和第 21 行,或者如果表格行有特定的 name 或 @ 987654323@?
编辑:正确代码如下:
$('table tr:not(:first-child,[name=header])').mouseover(function() {
$(this).removeClass('hovered_error');
$(this).addClass('hovered');
}).mouseout(function() {
$(this).removeClass('hovered');
});
【问题讨论】:
-
$('table tr:not(:eq(10),:eq(20))')... 因为 eq 适用于基于 0 的索引
-
:not也可以应用于类:not(.class)或:not([name=somerandomnamelol]) -
@Spokey - 这是正确的吗? '$('table tr:not(:first-child),:not([name=header])').mouseover(function() {'
-
$('table tr:not(:first-child, [name=header])')应该做的伎俩或尝试链接他们$('table tr:not(:first-child):not([name=header])') -
@Spokey - 在答案中弹出它,我会标记为已回答!
标签: jquery html-table highlight tablerow