开发者

Selecting all TRs where a specific TD contains specific text

开发者 https://www.devze.com 2023-04-13 07:35 出处:网络
Trying to select all rows where a cell in a specific location contains a specific value. example: <table>

Trying to select all rows where a cell in a specific location contains a specific value.

example:

<table>
  <tr>
    <td>1</td>
    <td>MO</td>
    <td>MO Williams</td>
  </tr>
  <tr>
    <开发者_开发问答;td>2</td>
    <td>PG</td>
    <td>MO Williams</td>
  </tr>
</table>

I want to ONLY select the rows where the 2nd contains MO.

I've tried this:

     $('tr:has(td:eq(1):contains(MO))') 

but that doesn't work. Thank you.


Selects all td elements:

$("tr").find("td:eq(1):contains('MO')")

working example: http://jsfiddle.net/hunter/jBbS7/


Selects all tr elements:

$("tr").find("td:eq(1):contains('MO')").parents("tr");

working example: http://jsfiddle.net/hunter/jBbS7/4/

0

精彩评论

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

关注公众号