JSFiddle - React, Tailwind, and code Playground

HTML

<h2>Option 1</h2>
<table id="table-1">
<tbody>
    <tr>
        <td><input type="radio" name="one" /></td>
        <td><input type="radio" name="one" /></td>        
    </tr>
    <tr>
        <td><input type="radio" name="two" /></td>
        <td><input type="radio" name="two" /></td>        
    </tr>
    <tr>
        <td><input type="radio" name="three" /></td>
        <td><input type="radio" name="three" /></td>        
    </tr>
</tbody>
</table>

<h2>Option 2</h2>
<table id="table-2">
<tbody>
    <tr>
        <td><input type="radio" name="four" /></td>
        <td><input type="radio" name="four" /></td>        
    </tr>
    <tr>
        <td><input type="radio" name="five" /></td>
        <td><input type="radio" name="five" /></td>        
    </tr>
    <tr>
        <td><input type="radio" name="six" /></td>
        <td><input type="radio" name="six" /></td>        
    </tr>
</tbody>
</table>

CSS

h2, table {
    margin: 15px 0;
}

JavaScript

$('#table-1').on('click', 'input[type=radio]', changeLastBackground);
$('#table-2').on('click', 'input[type=radio]', changeLastInColumnBackground);

function changeLastBackground(e) {
    var input = $(this),
        inputs = input.closest('table').find('input'),
        index = inputs.index(input);
    
    if (index === (inputs.length-1)) {
        input.parent().css('background-color', 'blue');
    }
}

    
function changeLastInColumnBackground() {
    var input = $(this),
        inputs = input.closest('tr').find('input'),
        index = inputs.index(input);
    
    inputs.parent().css('background-color', 'transparent');
    
    if (index === (inputs.length-1)) {
        input.parent().css('background-color', 'blue');
    }
}