gpt4 book ai didi

jquery - 如何使用 jquery 计算 元素的数量

转载 作者:行者123 更新时间:2023-12-01 06:28:27 27 4
gpt4 key购买 nike

我是 jquery 新手,我想计算表中的现有元素,html 结构如下:

<table summary="">
<tr>
<td>
<table id="myid" some more attributes> <-- i got that id and
<tbody>
<tr>foo</tr> <---counting
<tr>bar</tr> <---counting
</tbody>
</table>
</td>
</tr>
</table>
HTML is apex gernerated.

我已经尝试过 jQuery: count number of rows in a table 中的 jquery 语句还有很多次,但对我来说没有任何作用。我不起作用的“解决方案”是

 $("table[id='myid'] > tbody >tr").length

 $('table#myid >tbody:last >tr').length

感谢您的任何提示和技巧

马里奥

最佳答案

使用$('table#myid tr').length​

引用文献:

关于jquery - 如何使用 jquery 计算 <tr> 元素的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12198360/

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