开发者

Selecting all TRs where a specific TD contains specific text

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜