js 获取复选框所有选中的值

<form>
<input type="checkbox" name="game" value=111>111
<input type="checkbox" name="game" value=222>222
<input type="checkbox" name="game" value=333>333
<input type="checkbox" name="game" value=444>444
<input type="checkbox" name="game" value=555>555
<input type="button" value="click" onclick="show()">
</form>

获取

<script>
function show(){
items = document.getElementsByName("game");
data = [];
for(x in items){
if(items[x].checked)
data.push(items[x].value);
}
alert(data);
原文地址:https://www.cnblogs.com/ychun/p/14416260.html