Tom
Tom

Reputation: 2230

jQuery selector for a tr with a specific class in a specific table

I have a table, like below, and I want to add an event of the click of any tr with the class = hover.

Before the need to include the hover class, this worked: $('#delegation tbody tr'); now, I feel like I've tried placing .hover in every imaginable location within that selector, but can't seem to get it.

<table id="delegation">
  <tbody>
    <tr class="hover">
        <td>

        </td>
    </tr>
    <tr>
        <td>

        </td>
    </tr>
</tbody>

Upvotes: 0

Views: 3514

Answers (3)

Jonathan Naguin
Jonathan Naguin

Reputation: 14766

Try with:

$('#delegation tbody tr.hover')

Upvotes: 2

A. Wolff
A. Wolff

Reputation: 74420

If i understand what you are looking for:

$('#delegation').find('tr.hover').on('click',function(){...});

Upvotes: 0

p e p
p e p

Reputation: 6674

You can use this:

$('tr.hover', $('#delegation'))

Upvotes: 0

Related Questions