简体   繁体   English

如何使用JavaScript取消选中Struts2中的单选按钮

[英]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: 我的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. Struts2 <s:radio>标签为每个生成的单选按钮提供唯一的ID。 So using isPriTobaccoUsrId id is not an option, use class of the element as selector. 因此,不能使用isPriTobaccoUsrId id,而应使用元素的类作为选择器。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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