Posted By

mattvbiggs on 06/06/12


Tagged

jquery checkbox highlight


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

spee66
BrockSamsom


jQuery: Highlight Rows Using Checkbox


 / Published in: jQuery
 

The following code snippet will highlight the row in a table when the checkbox is checked. It will remove the highlight when the checkbox is unchecked. This will work for basic as well as a GridView.

The "input:not(#selectAll)" will ignore the row that contains a SelectAll checkbox with the ID "selectAll".

Note: I had a css class defined as highlight where I set the background-color property.

  1. $('#SurveyGrid input:not(#selectAll)').click(function () {
  2. if ($(this).attr("checked") == true) {
  3. $(this).parent().parent().addClass('highlight');
  4. } else {
  5. $(this).parent().parent().removeClass('highlight');
  6. }
  7. });

Report this snippet  

You need to login to post a comment.