[英]Manipulating tr's child elements not working
I just got stuck again, perhaps someone else can spot the problem easier. 我只是再次陷入困境,也许其他人可以更轻松地发现问题。 The 1st tr's children (such as table cells) don't change background on hovering with this code: 第一个tr的子代(例如表格单元格)在使用以下代码进行悬停时不会更改背景:
$("#target tr:eq(1).find("*")").hover(function(){
$(this).css("background", "#fff");
})
<table id="target">
<tr><td\>
content
</td></tr>
<tr><td\>
content
</td></tr>
</table>
Is it the quotes? 是引号吗?
$("#target tr:eq(1)").find("*").hover(function () {
//^^ move find outside the seletor
$(this).css("background", "#fff");
});
:eq() index starts from 0
if you want 1st tr us .eq(0)
:eq()索引从0
开始,如果您想进行.eq(0)
$("#target tr:eq(1)").find("*").hover(function () { $(this).css("background", "#fff"); },function(){ $(this).css("background", "blue"); //get old color back });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.