0
嗨,我試圖讓一個複選框的值,並指定檢查所有網頁上相同的ID checkboxed值。但是我嘗試不工作,這裏是我在做什麼多值複選框jQuery的問題
$('.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
我不是爲複選框所獲得的價值,並沒有被選中。我做錯了什麼?
<<所有checkboxed與頁面上相同的ID >> ID必須是上下文頁上是唯一的。對於作爲選擇醜陋的編碼使用:'$(「:複選框[ID = ssrBox]」)' –
@roasted我希望所有的複選框是相同的值,但?我有點失落 – Squirtle
一個ID應該永遠是唯一的。改爲使用班級。 – Sumurai8