我想循環下面的效果:效果,我可以檢查幾個複選標記,當我選擇「翻轉」按鈕,底部的複選標記將出現,對應於頂部的複選框。我寧願使用.each(function() {
循環。我如何將下面的腳本代碼轉換爲循環? (下面的代碼確實有效,但我試圖將它變成一個循環。)感謝您的時間和幫助。把一個jQuery複選框的翻轉效果變成一個循環
原始下面的腳本:當選擇按鈕倒裝,所述相反類複選標記然後被選擇,對應於不opposite_checkboxes。
$(document).ready(function() {
var ID_top
var ID_btm
$("#copy").click(function() {
for (i = 1; i <= 6; i++) {
ID_top = "#A" + i;
ID_btm = ID_top + "_flip";
if ($(ID_top).prop("checked")) {
$(ID_btm).prop("checked", "checked");
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table dir="rtl" class="not_opposite">
<tr>
<td class="dot_wrap">
<label for="A1"><span class="hidden">A-1</span>
<input type="checkbox" value="A1" name="A1" id="A1" tabindex="1" class="A">
<span aria-hidden="true"> </span>
</label>
</td>
<td class="dot_wrap">
<label for="A4"><span class="hidden">A-4</span>
<input type="checkbox" value="A4" name="A4" id="A4" tabindex="4" class="A">
<span aria-hidden="true"> </span>
</label>
</td>
</tr>
</table>
<div class="button_wrapper">
<button class="inline" id="copy">FLIP</button>
<button class="inline" id="clear">CLEAR</button>
</div>
<table class="opposite">
<tr>
<td class="dot_wrap">
<label for="A1_flip"><span class="hidden">A-1</span>
<input disabled="true" type="checkbox" value="A1" name="A1" id="A1_flip">
<span class="flip" aria-hidden="true"> </span>
</label>
</td>
<td class="dot_wrap">
<label for="A4_flip"><span class="hidden">A-4</span>
<input disabled="true" type="checkbox" value="A4" name="A4" id="A4_flip">
<span class="flip" aria-hidden="true"> </span>
</label>
</td>
</tr>
</table>
謝謝你很好。劇本幫助了很多。如果我想添加一個循環,使我可以將複選框分成2個組,然後評估每個組的兩個組合。我如何添加該類型的效果/代碼? - – user7293417