我想創(chuàng)建一個組合游戲,使用復(fù)選框簽入一些元素
我需要在用戶選中復(fù)選框并與正確的數(shù)組進行比較時創(chuàng)建一個數(shù)組
我不知道是誰干的
這是我的輸入
<section class="draggable-items"> <div class="check-tool"> <input type="checkbox" class="checkbox-tool" name="tool" id="SBD710" value="SBD710"> <img class="draggable correct" draggable="true" src="img-game/WOOD/SBD710.png"> </div> <div class="check-tool"> <input type="checkbox" class="checkbox-tool" name="tool" id="SCS220" value="SCS220"> <img class="draggable correct" draggable="true" src="img-game/WOOD/SCS220.png"> </div> <div class="check-tool"> <input type="checkbox" class="checkbox-tool" name="tool" id="SB201" value="SB201"> <img class="draggable correct" draggable="true" src="img-game/WOOD/SB201.png"> </div> <div class="check-tool"> <input type="checkbox" class="checkbox-tool" name="tool" id="SB204" value="SB204"> <img class="draggable correct" draggable="true" src="img-game/WOOD/SB204.png"> </div> <div class="check-tool"> <input type="checkbox" class="checkbox-tool" name="tool" id=SBG700" value="SBG700"> <img class="draggable correct" draggable="true" src="img-game/WOOD/SBG700.png"> </div> </section> <button id="check" class="btn">Construye</button>
如果有人可以解釋一下如何使用 Push 方法創(chuàng)建該數(shù)組以及誰制作了該數(shù)組 與正確的組合數(shù)組比較
這是您的解決方案的演示
let check = function () { let checkboxes = document.querySelectorAll("input[type=checkbox]"); let result = []; for (let i = 0; i