获取多选input-选中后的值存数组

简介: 获取多选input-选中后的值存数组
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>循环多条选中input值  值存数组-获取选中input存数组</title>
</head>
<body>
  循环多条选中input值  值存数组-获取选中input存数组
  <input type="checkbox" name="Fruit"  value="1" checked="checked" />
  <input type="checkbox" name="Fruit"  value="2" checked="checked" />
  <input type="checkbox" name="Fruit"  value="3" checked="checked" />
</body>
<script type="text/javascript">
  var nodeValue = [];
    function getValue(Fruit){
      var node = document.getElementsByName(Fruit);
      var len = node.length;
      for (var i = 0; i < len; i++) {
        if (node[i].checked) {
          nodeValue.push(node[i].value);
        }
      }
    }
    getValue("Fruit");
    console.log(nodeValue);
</script>
</html>

相关文章
|
7月前
LayUI清空下拉框的值
LayUI清空下拉框的值
116 0
|
前端开发
element ui el-table 多选 表头全选框替换文字
element ui el-table 多选 表头全选框替换文字
1475 0
|
19天前
|
JavaScript
Element_select 选择器 选中框中显示不了选中的值
解决Vue中`el-select`选择器不显示选中值的问题:在`selectChanged`方法中添加`this.$forceUpdate()`,强制组件更新,使输入框显示选择的值。示例代码包括模板和方法。
|
7月前
全选或者单选checkbox的值动态添加到div
全选或者单选checkbox的值动态添加到div
28 0
|
10月前
使用 contenteditable=“true“ 实现的文本框全选内容
使用 contenteditable=“true“ 实现的文本框全选内容
47 0
|
JavaScript
关于复选框checkbox没有选中不能获取值的问题
关于复选框checkbox没有选中不能获取值的问题
144 0
关于复选框checkbox没有选中不能获取值的问题
动态添加input,然后获取所有的input框中的值
动态添加input,然后获取所有的input框中的值
【Layui】关于单选框的选中状态,下拉框默认显示
【Layui】关于单选框的选中状态,下拉框默认显示
604 0
【Layui】关于单选框的选中状态,下拉框默认显示
input checkbox 复选框大小修改
有的时候,需要使用复选框,但是复选框有时候默认的太小,这时候就需要加大复选框。 解决方法: 其实就是zoom属性,这个是放大的意思,可以设置为180%,这样就会比之前大很多。
1387 0