jQuery簡(jiǎn)易模態(tài)對(duì)話(huà)框

<!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">
    <title>Document</title>
    <style>
        .xiugai {
            position: fixed;
            top: 50%;
            left: 50%;
            border: 1px solid #aaaaaa;
            width: 600px;
            height: 300px;
            margin-top: -150px;
            margin-left: -300px;
            padding: 10px;
            z-index: 3;
        }
    
        .c2 {
            position: fixed;
            background: #777;
            right: 0px;
            left: 0px;
            top: 0px;
            bottom: 0px;
            /* height:100%;
        width:100%; */
            z-index: 2;
        }
    
        .hide {
            display: none;
        }
    </style>
</head>

<body>
    <p>
        <input type="button" value="添加">
        <input type="button" value="全選">
        <input type="button" value="取消">
        <input type="button" value="反選">
    </p>

    <table border="1">
        <thead>
            <tr>
                <td>選擇</td>
                <td>主機(jī)名</td>
                <td>端口</td>
            </tr>
        </thead>
        <tbody id="tb">
            <tr>
                <td>
                    <input type="checkbox">
                </td>
                <td>1.1.1.2</td>
                <td>120</td>
                <td>
                    <input type="button" value="修改">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox">
                </td>
                <td>1.1.1.3</td>
                <td>130</td>
                <td>
                    <input type="button" value="修改">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox">
                </td>
                <td>1.1.1.4</td>
                <td>140</td>
                <td>
                    <input type="button" value="修改">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox">
                </td>
                <td>1.1.1.5</td>
                <td>150</td>
                <td>
                    <input type="button" value="修改">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="checkbox">
                </td>
                <td>1.1.1.6</td>
                <td>160</td>
                <td>
                    <input type="button" value="修改">
                </td>
            </tr>
        </tbody>
    </table>
    <div class ="xiugai hide">
        <div>
            <input type = "text">
        </div>
        <div>
            <input type = "text">
        </div>
        <div>
            <input type = "button" value="取消">
        </div>
        <div>
            <input type = "button" value="確定">
        </div>
    </div>
    <div class="c2 hide"></div>
    <script src="jquery-1.12.4.js"></script>
    <script>     
        $("p input[value = '全選']").click(function () {
            $("table :checkbox").prop("checked", true);
        })
        $("p input[value = '取消']").click(function () {
            // $("table :checkbox").prop("checked", false);
            $("table :checkbox").each(function () {
                this.checked = false;
            })
        })
        $("input[value = '反選']").click(function () {
            $("table :checkbox").each(function () {
                if (this.checked == true) {
                    this.checked = false
                }
                else
                    this.checked = true;
            })

        })
        $("input[value = '添加']").click(function () {

        })
        $("input[value = '修改']").click(function () {
            $(".xiugai").removeClass("hide");
            $(".c2").removeClass("hide");
            var IPaddress = $(this).parent().siblings().eq(1).text();
            var port  = $(this).parent().siblings().eq(2).text();
            $($(".xiugai input[type = 'text']")[0]).val(IPaddress);
            $($(".xiugai input[type = 'text']")[1]).val(port);
            // $(".xiugai input[type = 'text']").val(prot);
            // console.log($(".xiugai input[type = 'text']")[0]);
            // console.log($(".xiugai input[type = 'text']")[1]);//加數(shù)組后位dom對(duì)象 需要轉(zhuǎn)化為jQuery對(duì)象
            // console.log($(".xiugai input[type = 'text']"));
        })
        $(".xiugai input[value = '取消']").click(function () {
            $(".xiugai").addClass("hide");
            $(".c2").addClass("hide");
            $(".xiugai input[type = 'text']").val("");
        })
        $(".xiugai input[value = '確定']").click(function () {
            $(".xiugai").addClass("hide");
            $(".c2").addClass("hide");
            var currentIp = $($(".xiugai input[type = 'text']")[0]).text();
            var currentPort = $($(".xiugai input[type = 'text']")[1]).text();
            
        })

    </script>
</body>

</html>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容