如何找到< tr>在< table>内部深度为1?

问题描述:

$(this).parents('table:first').find('tr'))

以上内容将在table内部递归搜索tr,如何使其仅搜索顶部的tr?

The above will search for tr inside table recursively,how to make it only search for the top tr?

编辑

children无法正常工作:

alert($(this).parents('table:first').children('tr').length)

给出0

$(this).parents('table:first').find('> tbody > tr, > tr')

将抓住表,然后找到所有属于tbody的直接子代的tr和那些属于该表的直接子代的tr.

Will grab the table and then find all tr's that are direct children of tbody and those tr's that are direct children of the table.

在浏览器添加tbody和不添加浏览器的两种情况下均应工作

Should work in both cases where the browser adds tbody and when the browser does not