Mati_1 30 Newbie Poster

I have this code which I want to use but its color switching function doesn't work the way I want. Once I highlighted the target cells with one color, I also would like to highlight again with a different color without changing the color of the previously highlighted cells. Can somone help me with this, please? Here is a working example https://jsfiddle.net/a05nwahr/ I can only work with one color here only. Please ignore the messiness in the code, I hope you can see the problem in jquery. thanks.

// JavaScript Document
$(document).ready(function() {

$('.selector').each(function() {
    $(this).on('click', check); 
});
    $('.all').each(function() {
       $(this).on('click', all); 
    });

function all(event) {

        if($(this).is(':checked')){  $("input:checkbox:not(:checked)",$(this).parents('form')).not(this).prop("checked","checked");
    } else {
        $("input:checkbox(:checked)",$(this).parents('form')).not(this).prop("checked","");
    }

    //$('.selector').prop("checked", this.name === "SelectAll");

    check(event);
}

function check(event) {
    var checked = $(".selector:checked").map(function () {
        return this.name
    }).get()
    $('td').css('background', '#fff').filter(function () {
        return $.inArray($(this).text(), checked) >= 0
    }).css('background', $('#nextColor').val())
    if ($(this).is(".selector"))
        $('.all').not(this).prop("checked", false)

}

 $( "#Hidden").on( "click", function() {
        $(".selector").toggle();
    });

});