如何在嵌套的html表中获取所有主表行

时间:2014-10-02 02:51:48

标签: javascript html

我有一张如下表格 enter image description here

我想从主表中获取所有行,但我得到了所有行,包括master和child / nested表。我的代码如下----

 var $rows = $('#tableID tr:has(td)');

请帮助我......

2 个答案:

答案 0 :(得分:0)

应该是$('#tableID>tr:has(td)');这将选择直接后代,而您选择所有后代。

答案 1 :(得分:0)

您可以尝试使用this

var tr = $('#tableID tr').not('table table tr').not('tr:has(table)');