This works and will take care of unchecked conditions too. $('table tr[id^=row] :checkbox').click(function(){ $$ = $(this); $text = $$.parent().parent().find('.email, .contact');
if($$.is(':checked')) { $text[0].value = 'Email Checked'; $text[1].value = 'Contact Checked'; } else $checkbox.val(''); }); On Jan 18, 11:41 am, LexHair <jdpugl...@hotmail.com> wrote: > I have a table structure with a multiple rows containing a checkbox > input and 4 text inputs with distinct classes. I want to prefill two > of the text inputs in the same row where the checkbox is checked. > Example code for the first two rows: > > <table> > <tr id="row1"> > <td><input type="checkbox" /></td> > <td><input type="text" class="email" /></td> > <td><input type="text" class="contact" /></td> > <td><input type="text" class="realname" /></td> > <td><input type="text" class="sport" /></td> > </tr> > <tr id="row2"> > <td><input type="checkbox" /></td> > <td><input type="text" class="email" /></td> > <td><input type="text" class="contact" /></td> > <td><input type="text" class="realname" /></td> > <td><input type="text" class="sport" /></td> > </tr> > </table> > > I need help me crafting the correct selector to focus control onto the > text input for the input with class="contact" and class="email". I can > write the function to manipulate the attributes but I can't figure out > the selector. I haven't had any luck with "prev ~ siblings" or "prev + > next". Thanks in advance.