开发者

How to find <tr> inside <table> with depth 1?

$(this).pare开发者_如何学Pythonnts('table:first').find('tr'))

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

EDIT

children is not working as expected:

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

gives 0


$(this).parents('table:first').find('> 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.

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


$('table > tr')

This will find <tr> tags that are direct children of the table. If the rows are inside a tbody, you'd have to do this: $('table > tbody > tr')


$('table > tr') should work correctly. Or $('table').children('tr').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜