如何找到< tr>在< table>内部深度为1? [英] How to find <tr> inside <table> with depth 1?

查看:60
本文介绍了如何找到< 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

这篇关于如何找到< tr>在< table>内部深度为1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆