简体   繁体   中英

How to uncheck radio button javascript

I have the below radio button. When it is clicked it is not possible to clear the radio button.

the code is

<td class="Label">
<input class="Label" type="radio" name="reviewoptions_{@id}" value="other" onClick="reAssign({count(../bankguaranteedata)},document.lending.guaranteereviewoptions,this,{@id})">
<xsl:if test="guaranteereviewoptions/reviewoptions[@id='other']='checked'">
<xsl:attribute name="checked"/>
</xsl:if>
</input>Other</td>

is it possible that when its clicked again it will clear the radio button?

无法取消选择 HTML 中的单选按钮选项,出于某些原因,您可能喜欢阅读此内容: https : //ux.stackexchange.com/questions/13511/why-is-it-impossible-to-取消选择-html-radio-inputs

i actually use this:

var elements = document.getElementsByTagName("input");

for (var i = 0; i < elements.length; i++) {
        if (elements[i].type == "radio") {
            elements[i].checked = false;
        }
    }

try this

 if($('#checkboxID').is(':checked')){
         $('#checkboxID').attr('checked', false);
    }else{
        $('#checkboxID').attr('checked', true);
}

this Code is using jquery

you might try using a reset input.

<input type='reset' />

call reset for the form radio buttons are in.

document.getElementById("radiobuttonsform").reset(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM