JS实现全选和全不选

2021-03-25 13:26

阅读:654

标签:cti   class   span   style   inpu   ble   har   rip   oct   

DOCTYPE html>
html>
    head>
        meta charset="utf-8">
        title>全选和全不选title>
        script>
            function selectAll(){
                var check1 = document.getElementById("checkbox1");
                //var checks = document.getElementsByTagName("input");
                var checks = document.getElementsByName("checkbox1");
                for(var i=1;ichecks.length;i++){
                    checks[i].checked = check1.checked;
                }
            }
        script>
    head>
    body>
        table>
            tr>
                td>input type="checkbox" name="checkbox1" id="checkbox1" onclick="selectAll()">td>
            tr>
            tr>
                td>input type="checkbox" name="checkbox1">td>
            tr>
            tr>
                td>input type="checkbox" name="checkbox1">td>
            tr>
            tr>
                td>input type="checkbox" name="checkbox1">td>
            tr>
            tr>
                td>input type="checkbox" name="checkbox1">td>
            tr>
        table>
    body>
html>

 

JS实现全选和全不选

标签:cti   class   span   style   inpu   ble   har   rip   oct   

原文地址:https://www.cnblogs.com/yxfyg/p/12656281.html


评论


亲,登录后才可以留言!