gpt4 book ai didi

Jquery选择器: Count element with attribute on the second tr

转载 作者:行者123 更新时间:2023-12-01 08:00:22 24 4
gpt4 key购买 nike

我想知道如何获取第二个TR上具有特定属性的元素的数量。

我尝试过的:

$("[Chk_RPQSelection_col=1] tr:nth-child(2)").length

$("tr:nth-child(2) [Chk_RPQSelection_col=1] ").length

感谢您的帮助!

最佳答案

选择器中没有空格:

$('tr:nth-child(2)[Chk_RPQSelection_col="1"]').length

将找到所有类似表的第二个子项的 TR

<table>
<tr Chk_RPQSelection_col="1"></tr>
<tr Chk_RPQSelection_col="1"></tr> <!-- this one -->
<tr Chk_RPQSelection_col="1"></tr>
<tr Chk_RPQSelection_col="1"></tr>
<tr Chk_RPQSelection_col="1"></tr>
</table>

<table>
<tr Chk_RPQSelection_col="3"></tr>
<tr Chk_RPQSelection_col="1"></tr> <!-- and this one -->
<tr Chk_RPQSelection_col="4"></tr>
</table>

编辑:

要计算第二个 TR 内具有该属性的 TD,您可以执行以下操作:

$('tr:nth-child(2)').find('td[Chk_RPQSelection_col="1"]').length

关于Jquery选择器: Count element with attribute on the second tr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20222014/

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