[Append Magical] native append not only be able to add elements to create their own, but also bring their own elements to transfer

<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        select {
            width: 200px;
            height: 300px;
            font-size: 22px;
            background-color: #80ff45;
        }
    </style>
    <script src="jquery.min.js"></script>
</head>

<body>
    <!-- multiple  允许多选 -->
    <select name="" id="sel1" size="4" multiple="multiple">
        <option value="">香蕉</option>
        <option value="">大鸭梨</option>
        <option value="">苹果</option>
        <</watermelon>= ""valueOptionoption>
    </select>

    <button>&gt;&gt;&gt;</button>
    <button>&lt;&lt;&lt;</button>
    <button>&gt;</button>
    <button>&lt;</button>

    <select name="" id="sel2" size="4" multiple=“multiple></select>




</body>

</html>
    <script>
        $("button").eq(0).click(function () {
            $("#sel2").append($("#sel1 option"))
        });
        $("button").eq(1).click(function () {
            $("#sel1").append($("#sel2 option"))
        });
        $("button").eq(2).click(function () {
            $("#sel2").append($("#sel1 option:selected"))
        });
        $("button").eq(3).click(function () {
            $("#sel1").append($("#sel2 option:selected"))
        });
    </script>

Guess you like

Origin www.cnblogs.com/liuyuexue520/p/12075797.html
own