嗨,我正在尝试获取复选框的值,并将选中的值分配给页面上具有相同 ID 的所有复选框。但是我的尝试不起作用,这就是我正在做的
$('.add_button').click(function() { //they click a div named added
selected=$('#ssrBox').val(); //I get the id of the checkbox and the values however I only get one value.
id=$(this).attr('id'); //I find the id of the div which is ssrBox
$('#ssrBox').change(function() { // I find the rest of the checkboxes with the same id and hopefully make them select the same value
$('#ssrBox').add(selected); //have the value being checked for all
});
<div class="grs-multi-select-area" style="height:120px;width:150px;">
<div class="grs-multi-select-box ">
<input id="ssrBox" class="ssremployeeid" type="checkbox" name="ssremployeeid[]"
value="1312">
Amanda Becker
</div>
<div class="grs-multi-select-box "> // same as above I just collapsed it for viewing purposes
<div class="grs-multi-select-box ">
<div class="grs-multi-select-box ">
</div> //closes main div
我没有得到复选框的值,也没有检查任何内容。我做错了什么?