My dynamic table is filled with checkboxes that can be checked or unchecked. I have created a jquery script that should change the background color of the table cell whenever a checkbox is modified. However, the script seems to have some bugs and doesn't always change the background color instantly.
Do you have any suggestions on how to fix this issue?
var check; $('[id^=approvalcd]').change(function(){ if($(this).is("checked") != check) { check = $(this).prop("checked"); $('.approvalROW'+$(this).prop('id').split('approvalcd')[1]).css('background-color', color); }else{ $('.approvalROW'+$(this).prop('id').split('approvalcd')[1]).css('background-color', 'inherit'); } });
HTML:
<td class='approvalROW" . $counter . "'> <input id='approvalcd" . $counter ."' name='ApprovalCd" . $counter . "' type='checkbox'></td>