jQuery:即使表单字段被隐藏,也可以检测单选按钮的更改(哪些被选中,哪些未被选中)
在一组单选按钮中,我需要检测选中的单选按钮和(自动)未选中的单选按钮 一个简单的例子:jQuery:即使表单字段被隐藏,也可以检测单选按钮的更改(哪些被选中,哪些未被选中),jquery,radio-button,Jquery,Radio Button,在一组单选按钮中,我需要检测选中的单选按钮和(自动)未选中的单选按钮 一个简单的例子: <div class="radio-container"> <input type="radio" name="choice" id="radio1" class="hidden-field"> <label for="radio1">Label
<div class="radio-container">
<input type="radio" name="choice" id="radio1" class="hidden-field">
<label for="radio1">Label 1</label>
<br>
<input type="radio" name="choice" id="radio2" class="hidden-field">
<label for="radio2">Label 2</label>
<br>
<input type="radio" name="choice" id="radio3" class="hidden-field">
<label for="radio3">Label 3</label>
</div>
这很有效,但是。。。仅当单选按钮可见时
如果我应用以下CSS:
.hidden-field {
display: none;
}
对上一个选定字段的检测不再运行(我也尝试使用可见性:hidden
)
我需要这个,因为我在一个非常常见的“CSS手风琴解决方案”中使用了这个技术,在这个解决方案中,点击标签标签来触发相应的隐藏单选按钮
请问,js中是否有任何解决方法?尝试。在('change',…)
上使用prop('checked')获取选中值。
.hidden-field {
display: none;
}