在以下代码中,如何选择<tr>
元素的所有<td>
元素,其中的图片以cancelled.png
结尾?我不知所措......
<table>
<tr> <----- select this whole tr
<td>
<img src="/images/icons/invoice-cancelled.png" alt="cancelled" />
<a href='/orders/invoice.aspx?invoiceid=63'>X1087</a>
</td>
... other tds, some with "-cancelled.png" others with something different
</tr>
....
</table>
答案 0 :(得分:5)
$('tr:has(td img[src$="cancelled.png"])')
说明:
(tr) Select All Table Rows
(:has()) That Have:
(td) a table data
(img) with an image in it
([src$="cancelled.png"]) that has an ttribute of 'src' that ends($=) in
'cancelled.png'