zoukankan      html  css  js  c++  java
  • 全选反选以及取消

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>模态对话框</title>
        <style>
            .hide{
                display: none;
            }
            .c1{
                position: fixed;
                top:0;
                left:0;
                right: 0;
                bottom:0;
                background-color:black ;
                opacity: 0.6;
                z-index: 9;
    
    
            }
            .c2{
                 500px;
                height: 400px;
                background-color: white;
                position: fixed;
                left: 50%;
                top:50%;
                margin-left: -250px;
                margin-top:-200px ;
                z-index:10;
    
    
            }
        </style>
    </head>
    <body style="margin: 0;">
    <div>
        <input type="button" value="添加" onclick="ShowModel()";>
        <input type="button" value="全选" onclick="ChooseAll()";>
        <input type="button" value="取消" onclick="CancelAll()";>
        <input type="button" value="反选" onclick="ReverseAll()";>
        <table>
            <thead>
            <tr>
                <th>请选择</th>
                <th>主机名</th>
                <th>端口</th>
            </tr>
            </thead>
            <tbody id="tb">
            <tr>
                <td><input type="checkbox"></td>
                <td>1.1.1.1</td>
                <td>8888</td>
            </tr>
            <tr>
              <td><input type="checkbox"></td>
                <td>1.1.1.2</td>
                <td>8882</td>
            </tr>
            <tr>
              <td><input type="checkbox"></td>
                <td>1.1.1.3</td>
                <td>8883</td>
            </tr>
            </tbody>
        </table>
    </div>
    <!--遮罩层begin-->
    <div id="i1" class="c1 hide"></div>
    <!--遮罩层end-->
    
    <!--弹出框开始-->
    <div id="i2"class="c2 hide">
    
        <p><input type="text"/></p>
        <p><input type="text"/></p>
        <p><input type="text"/></p>
        <p>
            <input type="button" value="确定" onclick="AddModel()" >
            <input type="button" value="取消" onclick="AddModel()">
        </p>
    </div>
    <!--弹出框结束-->
    
    <script>
    function ShowModel() {
        document.getElementById('i1').classList.remove('hide');
         document.getElementById('i2').classList.remove('hide')
    
    }
    function AddModel() {
        document.getElementById('i1').classList.add('hide')
        document.getElementById('i2').classList.add('hide')
    }
    
    
    function ChooseAll() {
        var tbody=document.getElementById('tb');
        var tr_list=tbody.children;
        for (var i=0; i< tr_list.length;i++){
            var current_tr=tr_list[i];
            var checkbox=current_tr.children[0].children[0];
            checkbox.checked=true;
        }
    }
    function CancelAll() {
        var tbody=document.getElementById('tb');
        var tr_list=tbody.children;
        for (var i=0; i< tr_list.length;i++){
            var current_tr=tr_list[i];
            var checkbox=current_tr.children[0].children[0];
            checkbox.checked=false;
        }
    }
    function ReverseAll() {
        var tbody=document.getElementById('tb');
        var tr_list=tbody.children;
        for (var i=0; i< tr_list.length;i++){
            var current_tr=tr_list[i];
            var checkbox=current_tr.children[0].children[0];
            if (checkbox.checked){
                checkbox.checked=false;
            }
            else{
                checkbox.checked=true;
            }
        }
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    一则Entity Framework 学习中的问题
    用于主题检测的临时日志(861e835361d543a9b1b4e055dac9cf39 3bfe001a32de4114a6b44005b770f6d7)
    同一数据库如果处理多个完全不同的业务?
    swif debounce实现
    SQL Server 2008 下载地址(微软官方网站)
    fastreport 3的安装步骤
    修改windows server 2008 时间和日期格式 IIS配置后显示错误
    SQL server2000数据库备份和还原语句
    安装oracle,创建并启动oracle实例(创建克隆数据库,进度条在45%)就进行不下去了
    使用poi读写excel文件
  • 原文地址:https://www.cnblogs.com/nodchen/p/8453895.html
Copyright © 2011-2022 走看看