Unselect radio button

by Bruno G.

HTML

<table class="table">
    <tr>
        <td>
            <input type="radio" id="radio1" name="1" class="radio"/>
            <input type="radio" id="radio2" name="1" class="radio"/>
            <input type="radio" id="radio3" name="1" class="radio"/>
            <input type="radio" id="radio4" name="1" class="radio"/>
        </td>
    </tr>
</table>

JavaScript

$('.table').on('click', '.radio', function() {
    if (this.getAttribute('checked')) {
        $(this).siblings('.radio').addBack().removeAttr('checked');
    } else {
        $(this).attr('checked', true);
        $(this).siblings('.radio').removeAttr('checked');
    }
});