Background color selection

Background color selection

I have a problem with this code here:  https://jsfiddle.net/09aue04a/  When I try individual highlighting, it works. but I can't make it work for highlighting "Select all" with different colors. 

  1. $(function () {
  2.   $('.selector').on('click', function(e) {
  3.     var checked = this.name;
  4.     var selectedColor = '';

  5.     if (this.checked) {
  6.       selectedColor = $('#nextColor').val();

  7.       }
  8.     $('td').filter(function() {
  9.       return this.textContent == checked;
  10.     }).css('background-color', selectedColor);
  11.   });
  12.   
  13.   $('.all').on('click', function(e) {
  14.     var checked = this.name;
  15.     var selectedColor = '';

  16.     if (this.checked) {
  17.       selectedColor = $('#nextColor').val();

  18.       }
  19.     $('#form1').find('td').css('background-color', selectedColor);
  20.   });
  21. });