views:

67

answers:

2

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 posible to toggle the class of only an entire TR of inputs with a simple command?

+1  A: 

You can select by ID:

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

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

Nick Craver
@jimsmith: Note if your id's are actually `1`, `2`, etc. They wont work - valid id's cannot begin with a number.
prodigitalson
Yes that works. I knew there had to be an easy way. thanks a lot!
jimsmith
@ prodigitalson it's not the real id's I just use them as a simple example. thanks
jimsmith
@prodigitalson - Valid point :) I was just matching the example for simplicity sake. My current project leaves me with Huge$Annoying$ID$That$You$Hate$Wasting$Space$Arrrrrrrgh IDs, I'd love for a short number to be a problem...oh well .Net 4 around the corner.
Nick Craver
@Nick: i feel you on that one - mine are usually `$layoutContext_$dataObjectClass-$dbPrimaryKey` and those can get quite long when you consider i try to keep `$layoutContext` as semantic as possible and that depending on conventions `$dataObjectClass` can be horrendously long as well without using some sort of inflection (im looking at you Zend Framework).
prodigitalson
A: 

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.

Randal Schwartz
Not nessecarily.. in my opinion it takes a lot more to manage things by node order than directly by id. In many cases my `$layoutCotext` can be replaced by an id on parent element somewhere but sometimes not.
prodigitalson