繁体   English   中英

处理tr的子元素不起作用

[英]Manipulating tr's child elements not working

我只是再次陷入困境,也许其他人可以更轻松地发现问题。 第一个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>

是引号吗?

。找()

$("#target tr:eq(1)").find("*").hover(function () {
                    //^^ move find outside the seletor
    $(this).css("background", "#fff");
});

演示

: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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM