How to check if a TR contains a TD with a specific CSS class with jquery?

前端 未结 2 457
一生所求
一生所求 2021-01-11 16:09

I know you can use .find to find td:contains(\'text\'), but if I have a tr with say, 3 td\'s, and one of the td\'s might have class=

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-11 16:32

    To select any tr that has a td.specialclass:

    $('tr:has(td.specialclass)')
    

    Or if you have a tr (represented by this) and you simply want to check if it has such a td:

    if ($(this).find('td.specialclass').length)
    

提交回复
热议问题