Assuming you have this:

<table id="dj">
<tbody class="options">
  <tr>
    <td>Something here</td>
    <td><input type="checkbox" /></td>
  <tr>
</tbody>
</table>

You'd use this javascript:

$('#dj .options tr').each(function(){
   var self = $(this);
   self.find(':checkbox').click(function(){
       self.toggleClass('selected')
   });
});

I don't know if it's possible for the click event to fire on the
checkbox without it's value changing. If that happens you can use this
instead of toggleClass:

this.checked
  ? self.addClass('selected')
   : self.removeClass('selected');

And this CSS:

#dj .options tr.selected { background-color: #0FC }

cheers,
- ricardo
On Mar 16, 12:25 pm, bsisco <blake.si...@gmail.com> wrote:
> I have a django app where i have a model which contains a boolean
> (checkbox) field.  What i would like to do is change the corresponding
> table row color in the admin table based on whether or not this field
> is checked.  i have come to the conclusion that this is only possible
> with jquery.  i am a complete n00b when it comes to jquery so i was
> looking for some guidance/suggestions on how i might be able to
> accomplish this.
>
> Cheers

Reply via email to