2009-08-28 216 views
0

在下面的代码中,如何选择所有具有<td><tr>元素,并以cancelled.png结尾的图像?我很茫然......jQuery选择问题

<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> 

回答

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' 
+0

感谢。这帮助我得到了我需要的东西。 – Jason 2009-08-28 00:55:18