2009-08-28 7 views
0

Dans le code suivant, comment puis-je sélectionner tous les éléments <tr> qui ont un <td> avec une image se terminant par cancelled.png? Je suis à une perte ...jQuery Problème de sélection

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

Répondre

5
$('tr:has(td img[src$="cancelled.png"])') 

Explication:

(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

merci. Cela m'a aidé à obtenir ce dont j'avais besoin. – Jason