zoukankan      html  css  js  c++  java
  • HTML #模态对话框 (完成版)

    ###

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .c1{
                background-color: gray;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                opacity: 1;
            }
            .c2{
                background-color: white;
                position: fixed;
                top: 50%;
                left: 50%;
                height: 300px;
                width: 626px;
                margin-top: -150px;
                margin-left: -400px;
            }
            .c3{
                color: #000;
            }
            .hide{
                display: none;
            }
        </style>
    </head>
    <body>
        <input id="i1" type="button" value="添加">
        <table border="1px">
            <thead>
                <tr>
                    <th>主机名</th>
                    <th>IP</th>
                    <th>端口</th>
                    <th>配置</th>
                </tr>
            </thead>
            <tbody>
                <div id="i2" class="c1 hide">12</div>
                <tr>
                    <td>localhost</td>
                    <td>1.1.1.1</td>
                    <td>8080</td>
                    <td><input class="c3" type="button" value="编辑"><input type="button" value="删除"></td>
                </tr>
                <tr>
                    <td>localhost</td>
                    <td>1.1.1.2</td>
                    <td>3306</td>
                    <td><input class="c3" type="button" value="编辑"><input type="button" value="删除"></td>
                </tr>
                <tr>
                    <td>localhost</td>
                    <td>1.1.1.3</td>
                    <td>80</td>
                    <td><input class="c3" type="button" value="编辑"><input type="button" value="删除"></td>
                </tr>
            </tbody>
            <div id="i3" class="c2 hide">
                <div id="i4">
                    <input type="text" name="hostname" />
                    <input type="text" name="ipaddr" />
                    <input type="text" name="port"/>
                </div>
                <input type="button" value="取消">
                <input type="button" value="确定">
            </div>
        </table>
        <script src="jquery-3.2.1.js"></script>
        <script>
            $('#i1').click(function () {
                $('#i2,#i3').removeClass('hide');
    
            });
            $("input[value='取消']").click(function () {
                $('#i2,#i3').addClass('hide');
                $(".c2 input[type='text']").val('');
    
                });
            $('.c3').click(function () {
                var h = $('#i2,#i3').removeClass('hide');
                tds = $(this).parent().siblings();
                var hostname = $(tds[0]).text();
                var ipaddr = $(tds[1]).text();
                var port = $(tds[2]).text();
    //            console.log(hostname,ipaddr,port);
    //            var v1 = $('#i4').children("input[name='hostname']").val(hostname);
    //            var v2 = $('#i4').children("input[name='ipaddr']").val(ipaddr);
    //            var v3 = $('#i4').children("input[name='port']").val(port);
                var v1 = $(".c2 input[name='hostname']").val(hostname)
                var v2 = $(".c2 input[name='ipaddr']").val(ipaddr);
                var v3 = $(".c2 input[name='port']").val(port);
            })
        </script>
    </body>
    </html>

     ps:大家可以复制过去测试下。

    静态效果图:

    12 ###

    主机名IP端口配置
    localhost 1.1.1.1 8080
    localhost 1.1.1.2 3306
    localhost 1.1.1.3 80
  • 相关阅读:
    1 slow requests are blocked > 32 sec解决方法
    centos7下搭建ceph luminous(12.2.1)--无网或网络较差
    防止集群数据恢复设置
    ceph:health_warn clock skew detected on mon的解决办法
    Windows下判断jdk是否安装好以及环境变量是否配置好
    卸载Myeclipse10.5 报错“an error has occured.See the log file ...Uninstaller...”
    转: Laravel 自定义公共函数的引入
    windows下安装composer
    PHP与.Net的区别(一)接口
    phpStorm+XDebug配置
  • 原文地址:https://www.cnblogs.com/lwsup/p/7449843.html
Copyright © 2011-2022 走看看