Проблема выбора jQuery - PullRequest
       11

Проблема выбора jQuery

0 голосов
/ 28 августа 2009

В следующем коде как выбрать все элементы <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>

1 Ответ

5 голосов
/ 28 августа 2009
$('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'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...