Highlighting works for some cells, but not others
I'm dealing with this script for a while now, I couldn't fix this. Some cells are highlighted some are not. When you make a selection from the select box, the matching value's supposed to be highlighted. it only works for some cells. Can I get some help, please?
For example, if you select 1, it works. but it doesn't work for 2,3
.
- $("select").change(function () {
- var selectIndex = $(this).parent().index();
- var value = $(this).val();
- $('th', '.table2').each(function() {
- if($(this).index() === selectIndex) {
- if($(this).attr('value') == value) {
- $(this).css('background-color', 'yellow');
- }
- else {
- $(this).css('background-color', '');
- }
- }
-
- })
- });