简体   繁体   中英

How to uncheck a radio button in struts2 using javascript

I have the following radio button. After selecting any radio button, I have a button "CLEAR". On clicking this button, the radio button should be unchecked. Could anyone help me with this? Thanks in advance.

My code:

<s:radio id="isPriTobaccoUsrId" cssClass="hixFieldText" name="testPlanDto.isPriTobaccoUsr" list="#{'Y':'Yes','N':'No'}" />

My javascript:

$('#isPriTobaccoUsrId').attr('checked',false);
$('#isPriTobaccoUsrId').prop('checked',false);
$('#isPriTobaccoUsrId').buttonset('refresh');

I tried these but no luck.

Also tried:

$('#isPriTobaccoUsrId').removeAttr('checked');
$('#isPriTobaccoUsrId').removeAttr('checked');

Struts2 <s:radio> tag gives unique id-s to each generated radio button. So using isPriTobaccoUsrId id is not an option, use class of the element as selector.

$('.hixFieldText').prop('checked', false);

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