jimsmith
jimsmith

Reputation: 21

jQuery toggle input classes in only 1 TR table row

I have a table with a number of rows each row contain several input fields, example

<tr id='1'>
 <td><input id='a' class='inputa'></td>
 <td><input id='ab' class='inputa'></td>
 <td><input id='abc' class='inputa'></td>
</tr>
<tr id='2'>
 <td><input id='b' class='inputa'></td>
 <td><input id='bc' class='inputa'></td>
 <td><input id='bcd' class='inputa'></td>
</tr>

etc..

the inputs have all the same classes because I toggle the input class of the whole table, but is it possible to toggle the class of only an entire TR of inputs with a simple command?

Upvotes: 0

Views: 412

Answers (2)

Randal Schwartz
Randal Schwartz

Reputation: 44056

You're definitely suffering from "id-itis" there though. Seriously, if you have a well-known ID at the top of your structure, you don't need to ID everything else... it's just a lot more work.

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630389

You can select by ID:

$("#1 input").toggleClass("inputa")

Is this what you're after? If not please clarify a bit more.

Upvotes: 1

Related Questions