trt_v trt_v - 3 months ago 5x
jQuery Question

how to un-check Radio Button with single click which is checked by default

I have a radio button which by default comes checked when the page loads ,and user can un_check if he want by single click but its not working in single click .. after three clicks the radio button un_checked.
Please see
JSFIDDLE . in the code the radio button with value 7 comes with checked by default , I can be able to un_check by clicking three times on there any way to un_check it by just single click .Any help is appreciated.
Thank you.

<td style="padding-right:0px;"><input type="radio" name="TEST" onclick=" var allRadios = document.getElementsByName('TEST'); var booRadio; var x = 0; for(x = 0; x < allRadios.length; x++){ allRadios[x].onclick = function() { if (booRadio == this) { this.checked = false; booRadio = null; }else{ booRadio = this; } }; }" value="7" CHECKED> 7</td>


A JQuery solution, if you assing a class radioClass to your radio buttons:

(function () {
    $('.radioClass').on('mouseup', function (e) {
    var xRadioB = this;
    if ($(xRadioB).is(':checked')) {
        setTimeout(function () {
        $(xRadioB).prop('checked', false);
      }, 5);

JSfiddle Example: