• 原生js获取到页面上所有的checkbox


    <!DOCTYPE html>
    <html lang="en">

    <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">
    <meta name="author" content="">
    <title>获取页面所有的checkbox</title>
    </head>

    <body>
    <input type="checkbox" name="box1" id="box1">box1
    <input type="checkbox" name="box2" id="box2">box2
    <input type="checkbox" name="box3" id="box3">box3
    <input type="checkbox" name="box4" id="box4">box4
    <input type="checkbox" name="box5" id="box5">box5
    <input type="checkbox" name="box6" id="box6">box6
    <script>
    var inputs = document.getElementsByTagName("input");
    var boxs = [];
    for (let i = 0; i < inputs.length; i++) {
    if (inputs[i].type == "checkbox") {
    boxs.push(inputs[i])
    }
    }
    console.log(boxs)
    </script>
    </body>

    </html>

  • 相关阅读:
    友元函数
    异常处理
    RTTI
    接口类
    纯虚函数和抽象类
    虚函数与虚析构函数原理
    查看表空间使用率及shrink 表空间
    RAC fail over 测试
    js判断数组中是不是有某个元素
    layui 表格图片放大
  • 原文地址:https://www.cnblogs.com/quitpoison/p/9797744.html
Copyright © 2020-2023  润新知