ychun

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);

 

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-08-20
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2021-10-23
  • 2021-10-22
  • 2021-12-06
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案