如何使用JavaScript取消选中Struts2中的单选按钮 [英] How to uncheck a radio button in struts2 using javascript

查看:109
本文介绍了如何使用JavaScript取消选中Struts2中的单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下单选按钮.选择任何单选按钮后,我有一个按钮清除".单击此按钮时,应取消选中单选按钮.有人可以帮我吗?预先感谢.

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.

我的代码:

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

我的JavaScript:

My javascript:

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

我尝试了这些,但是没有运气.

I tried these but no luck.

也尝试过:

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

推荐答案

Struts2 <s:radio>标记为每个生成的单选按钮提供唯一的ID.因此,不能使用isPriTobaccoUsrId id,而应使用元素的类作为选择器.

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);

这篇关于如何使用JavaScript取消选中Struts2中的单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆