【发布时间】:2014-02-04 19:42:43
【问题描述】:
我有一组单选按钮和一个文本输入字段。当我单击文本输入时,使用 JavaScript 未选中单选按钮,但是当我在表单字段中输入内容然后重新选择单选按钮时,我无法删除要删除的文本。到目前为止,这是我的代码,如果有人可以帮助我在选择我知道我关闭的收音机时让文本框清除所有输入。
<input type="radio" id="radio1" name="radios" checked>
<label for="radio1">$10</label>
<input type="radio" id="radio2" name="radios" >
<label for="radio2">$25</label>
<input type="radio" id="radio3" name="radios" >
<label for="radio3">$50</label>
<input type="radio" id="radio4" name="radios" >
<label for="radio4">$100</label>
<input type="text" id="textInput">
<script>
<!-- to remove radio on text input click-->
$('#textInput').click(function () {
$.each($('input[type=radio]'), function () {
$(this).removeAttr("checked");
});
});
<!-- to remove text on text radio button click-->
$('input[type=radio]').click(function () {
$.each($('#textInput'), function () {
$(this).removeAttr("input");
});
});
</script>
【问题讨论】:
标签: javascript jquery html forms