Javascript 如何创建具有<;的所有ID的数组;输入类型=";复选框“&燃气轮机;在jQuery中?

Javascript 如何创建具有<;的所有ID的数组;输入类型=";复选框“&燃气轮机;在jQuery中?,javascript,jquery,html,checkbox,Javascript,Jquery,Html,Checkbox,以下是我的HTML代码: <!-- Following is the code for parent checkbox--> <input id="ckbCheckAll" class="custom-check ez-hide" type="checkbox" name=""></input> <!-- Following is the code for child checkboxes--> <input id="practice_6_1

以下是我的HTML代码:

<!-- Following is the code for parent checkbox-->
<input id="ckbCheckAll" class="custom-check ez-hide" type="checkbox" name=""></input>
<!-- Following is the code for child checkboxes-->
<input id="practice_6_191" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_191')" value="191" name="practice_topics_6[]"></input>
<input id="practice_6_190" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_190')" value="190" name="practice_topics_6[]"></input>
<input id="practice_6_191" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_191')" value="191" name="practice_topics_6[]"></input>
<input id="practice_6_192" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_192')" value="192" name="practice_topics_6[]"></input>
<input id="practice_6_193" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_193')" value="193" name="practice_topics_6[]"></input>
<input id="practice_6_195" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_195')" value="195" name="practice_topics_6[]"></input>
<input id="practice_6_196" class="custom-check ez-hide" type="checkbox" onchange="enable_text_boxes('practice_6_196')" value="196" name="practice_topics_6[]"></input>

现在,我想创建上述
HTML元素的id数组,并使用父复选框的click事件上的foreach循环访问该数组

也就是说,当选中父复选框时,所有子复选框也应选中,当取消选中父复选框时,所有子复选框也应取消选中

当用户逐个选中所有子复选框时,父复选框也应被选中;当用户在选中父复选框时取消选中任何子复选框时,父复选框也应被取消选中

在这方面你能帮我吗

另外,更重要的是,我不想在类选择器的帮助下访问子复选框,即class=“custom check”或class=“ez hide”,因为这些类对所有子复选框都是通用的。我想创建一个数组,然后在代码中访问这个数组。提前谢谢

使用

使用

var id_checkboxes = $('input[type="checkbox"]').map(function () {
    return this.id;
}).get();