Kris
Kris

Reputation: 3769

is there a way to select two classes at the same time in jquery?

I want to select:

<tr class='odd-row'>

and

<tr class='even-row'>

at the same time using jquery, is it possible?

Upvotes: 6

Views: 3268

Answers (3)

Balanivash
Balanivash

Reputation: 6867

You can use the multiple selectors. Check this

Upvotes: 0

jackJoe
jackJoe

Reputation: 11148

like this (use a comma):

$(".odd-row, .even-row").something

Upvotes: 2

Ariel
Ariel

Reputation: 26753

$('tr.even-row, tr.odd-row')

You can also do

$('.even-row, .odd-row')

If you don't care that it's a tr.

You don't have to pre-mark the rows with an odd/even class. You can also do:

$('tr:odd, tr:even')

And jQuery will figure out which are odd/even on its own.

Upvotes: 10

Related Questions