你不得不知道的jQuery基础之实验课(1)

目录

 

1、多选框互移

①、代码实现

②、实现效果图

2、表格修改

①、代码实现

②、实现效果图

3、会员注册基本样式

①、代码实现

②、实现效果图


1、多选框互移

①、代码实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>select</title>
</head>
<body>
    <div id="oneBox" style="width: 600px; height: 400px; margin: 40px auto; border: 2px solid black">
        <span style = "float: left;">
            <font color="green" face ="宋体">已有商品</font><br/>
            <select multiple="multiple" style="width: 100px; height: 200px;" id="left">
                <option class = "op01">iPhone6S</option>
                <option class = "op01">小米4</option>
                <option class = "op01">锤子TZ</option>
            </select>
            <p><a href="#" style="padding-left: 20px;"id="selectOneToRight"> >> </a></p>
            <p><a href="#" style="padding-left: 20px;"id="selectAllToRight"> >>> </a></p>
        </span>

        <span style = "float: right;">
            <font color="red" face ="宋体">未有商品</font><br/>
            <select multiple="multiple" style="width: 100px; height: 200px;" id="right">
                <option>三星Note3</option>
                <option>华为6s</option>
            </select>
            <p><a href="#" style="padding-left: 20px;"id="selectOneToLeft"> << </a></p>
            <p><a href="#" style="padding-left: 20px;"id="selectAllToLeft"> <<< </a></p>
        </span>
    </div>

    <script type="text/javascript" src="../js/jquery-3.4.1.js"></script>
    <script>
        /* 1. 选中单击去右边 */
        $("#selectOneToRight").click(function () {
            $("#left option:selected").appendTo($("#right"));
        });
        /* 双击去右边 */
        $(".op01").dblclick(function () {
            $("#left option:selected").appendTo($("#right"));

            $(".op01").dblclick(function () {
                $("#right option:selected").appendTo($("#left"));
            });
        });



        /* 2. 单击全部去右边 */
        $("#selectAllToRight").click(function () {
            $("#left option").appendTo($("#right"));
        });

        /* 3. 选中单击去左边 */
        $("#selectOneToLeft").click(function () {
            $("#right option:selected").appendTo($("#left"));
        });
        /* 4. 单击全部去左边 */
        $("#selectAllToLeft").click(function () {
            $("#right option").appendTo($("#left"));
        });
    </script>
</body>
</html>

②、实现效果图

多选框互移

2、表格修改

①、代码实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <table border="1">
        <tr>
            <td id="zhuji01">mysql-001</td>
            <td id="ip01">10.10.8.10</td>
            <td id="port01">15379</td>
            <td><a id ="regdit01" href="#">编辑</a></td>
        </tr>
        <tr>
            <td id="zhuji02">redls-001</td>
            <td id="ip02">10.10.9.10</td>
            <td id="port02">16379</td>
            <td><a id="regdit02" href="#">编辑</a></td>
        </tr>
        <tr>
            <td id="zhuji03">monitor-001</td>
            <td id="ip03">10.10.10.10</td>
            <td id="port03">17379</td>
            <td><a id="regdit03" href="#">编辑</a></td>
        </tr>
    </table>

    <div id="regdit" style="width: 300px;height: 200px; margin: 200px auto; background-color: cornflowerblue">
        <table style="margin: 0 auto; padding-top: 30px">
            <tr>
                <td>主机名:</td>
                <td>  <input id="zhuji" type="text" style="width: 100px;" /></td>
            </tr>
            <tr>
                <td> ip地址:</td>
                <td> <input id="ip" type="text" style="width: 100px;" /></td>
            </tr>
            <tr>
                <td>端口号:</td>
                <td><input id="port" type="text" style="width: 100px;" /></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <button type="submit"  id="submit">确认</button>
                    <button type="button" id="cancel">取消</button>
                </td>
            </tr>
        </table>
    </div>

    <script type="text/javascript" src="../js/jquery-3.4.1.js"></script>
    <script>

        $("#regdit").hide();
        // 第1个
        $("#regdit01").click(function () {
           $("#regdit").show();
           $("#zhuji").val( $("#zhuji01").text());
           $("#ip").val($("#ip01").text());
           $("#port").val($("#port01").text());

            // 点击确认 之后 修改表格中的数据
            $("#submit").click(function () {
                $("#zhuji01").text( $("#zhuji").val());
                $("#ip01").text( $("#ip").val());
                $("#prot01").text( $("#port").val());
            });
        });
        // 2
        $("#regdit02").click(function () {
            $("#regdit").show();
            $("#zhuji").val( $("#zhuji02").text());
            $("#ip").val($("#ip02").text());
            $("#port").val($("#port02").text());

            // 点击确认 之后 修改表格中的数据
            $("#submit").click(function () {
                $("#zhuji02").text( $("#zhuji").val());
                $("#ip02").text( $("#ip").val());
                $("#prot02").text( $("#port").val());
            });
        });
        // 3
        $("#regdit03").click(function () {
            $("#regdit").show();
            $("#zhuji").val( $("#zhuji03").text());
            $("#ip").val($("#ip03").text());
            $("#port").val($("#port03").text());

            // 点击确认 之后 修改表格中的数据
            $("#submit").click(function () {
                $("#zhuji03").text( $("#zhuji").val());
                $("#ip03").text( $("#ip").val());
                $("#prot03").text( $("#port").val());
            });
        });
        // 隐藏div
        $("#cancel").click(function () {
           $("#regdit").hide();
        });

    </script>

</body>
</html>

②、实现效果图

修改表格

3、会员注册基本样式

①、代码实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>register</title>
    <style>
        td{
            border: 1px solid red;
            width: 33%;
        }
        .title{
            color: white;
        }

    </style>
</head>
<body>
    <table width="100%" style="border: 1px solid black; height: 40px;">
        <tr>
            <td></td>
            <td></td>
            <td>
                <a href="#">登录</a>
                <a href="#">注册</a>
                <a href="#">购物车</a>
            </td>
        </tr>
    </table>
    <div style="width: 100%; height: 40px; background-color: #C75450;">
        <a class="title">首页</a>
        <a class="title">电脑办公</a>
        <a class="title">手机数码</a>
        <a class="title">孕婴保健</a>
        <a class="title">鞋靴箱包</a>
    </div>

    <div style="width:500px;height:500px; border: 1px solid black; margin: 30px auto; ">
        <table width = "80%" style="text-align: center; margin: 60px auto;" >
            <tr>
                <td colspan="2">
                    <p><strong>会员注册</strong></p>
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">用户名</td>
                <td style="width: 70%;">
                    <input style="float:left" type="text" value = "admin">
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">密码</td>
                <td style="width: 70%;">
                    <input style="float:left" type="password" />
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">确认密码</td>
                <td style="width: 70%;">
                    <input style="float:left" type="password" />
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">email</td>
                <td style="width: 70%;">
                    <input style="float:left" type="email" />
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">姓名</td>
                <td style="width: 70%;">
                    <input style="float:left" type="text" />
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">籍贯</td>
                <td style="width: 70%;">
                   <select style="float:left" >
                       <option select="selected">请选择</option>
                       <option>山东省</option>
                       <option>安徽省</option>
                   </select>
                    <select style="float:left" >
                        <option select="selected">请选择</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">姓名</td>
                <td style="width: 70%;">
                    <input style="float:left" type="text" />
                </td>
            </tr>

            <tr>
                <td style="width: 30%;">出生日期</td>
                <td style="width: 70%;">
                    <input style="float:left" type="text" />
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">验证码</td>
                <td style="width: 70%;">
                    <input style="float:left" type="text" />
                    <img src=".../">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button type="submit">注册</button>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

②、实现效果图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TomLazy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值