avs3323
avs3323

Reputation: 77

Select node based on its second class in jquery

I have a table with each row first given a class odd or even.

I also give one row in the table a "row_selected" class.

How do I select the row with the class "row_selected" with jquery?

I tried even the most general $('.row_selected') and that doesn't even work

Upvotes: 0

Views: 60

Answers (1)

Paul
Paul

Reputation: 141839

Make sure you do not have two class attributes. You want to have multiple classes in one attribute separated by spaces:

<tr class="odd row_selected">

Not:

<tr class="odd" class="row_selected">

Then you can select with all of:

$('.odd')              // Has class odd
$('.row_selected')     // Has class row_selected
$('.odd.row_selected') // Has both
$('.row_selected.odd') // Has both

Upvotes: 2

Related Questions