2010-04-13 30 views
2

我希望獲得所有在其中某個輸入元素的TR元素的數量。我應該如何繼續?Javascript/JQuery - 如何獲取特定子元素的數量

HTML:

<tbody> <tr> <td>Ignore this item 1</td> </tr> <tr> <td>Ignore this item 2</td> </tr> <tr> <td><input blablabla>... Include this TR...</td> </tr> </tbody>

謝謝!

+0

你是什麼意思,「得到號碼」?你的意思是你想要數它們嗎? – Pointy 2010-04-13 15:41:26

回答

5

$('tr:has(input)').length

+0

你真棒@電視 – Pointy 2010-04-13 15:42:40