Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery:即使表单字段被隐藏,也可以检测单选按钮的更改(哪些被选中,哪些未被选中)_Jquery_Radio Button - Fatal编程技术网

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