Highlighting works for some cells, but not others

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

  1. $("select").change(function () {

  2.   var selectIndex = $(this).parent().index();
  3.   var value = $(this).val();

  4.   $('th', '.table2').each(function() {

  5.    if($(this).index() === selectIndex) {

  6.       if($(this).attr('value') ==  value) {
  7.         $(this).css('background-color', 'yellow');
  8.       }
  9.       else {
  10.        $(this).css('background-color', '');
  11.       }
  12.     }
  13.     
  14.   })
  15. });