gpt4 book ai didi

jquery - 选择表内的 TD

转载 作者:行者123 更新时间:2023-12-01 02:34:40 24 4
gpt4 key购买 nike

在jQuery中,如何选择里面只有2个TD的所有TR?这是示例:

<table>
<tr>
<td></td>
</tr>
<tr> /* I only want to select this. */
<td></td>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>

最佳答案

您应该使用.filter()方法将 tr 减少到仅那些子项计数为 2

$('table tr').filter(function(){
return $(this).children().length === 2;
});

演示位于 http://jsfiddle.net/gaby/xTNcG/

关于jquery - 选择表内的 TD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8380619/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com