I have a checkbox list as a connected parameter. I want to color red some of the checkbox labels if the word 'Caution' appears in the label text. I can do this:
if ($('label[for="addNewRecord_u9_1_cbl"]').is(':contains("Caution")')) {
$('label[for="addNewRecord_u9_1_cbl"]').css('color', 'red');
}
else {
$('label[for="addNewRecord_u9_1_cbl"]').css('color', 'green');
}
However, this only works for the initial loading of the checkbox list. If previous selections change the content of the checkbox list, the color does not change. I tried using the .change event for the checkbox list, but it doesn't seem to work?
$('#addNewRecord_u9_1_cbl').change(function(){ if ($('label[for="addNewRecord_u9_1_cbl"]').is(':contains("Caution")')) {
$('label[for="addNewRecord_u9_1_cbl"]').css('color', 'red');
}
else {
$('label[for="addNewRecord_u9_1_cbl"]').css('color', 'green');
} });
I also tried just $('#addNewRecord_u9').change with no effect. Am I putting the .change on the wrong selector?
Thanks,
Cris