下拉框左右選擇,下拉框選擇

來源:互聯網
上載者:User

下拉框左右選擇,下拉框選擇

//下拉框左右選擇

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>        .left, .right {            float: left;            height: 250px;            width: 120px;            margin-left: 10px;        }        #select1, #select2 {            height: 200px;            width: 120px;        }    </style>    <script src="js/jquery-1.11.3.min.js"></script>    <script>       $(function () {           $("#buttonl1").click(function () {               $('#select1 option:selected').appendTo('#select2');           });           $("#buttonl2").click(function () {               var $reall=$("#select1 option");              $reall.appendTo($("#select2"));           })           $("#buttonr1").click(function () {               $("#select2 option:selected").appendTo("#select1");           })           $("#buttonr2").click(function () {               var $reall=$("#select2 option");               $reall.appendTo($("#select1"));           })           //雙擊選項           $('#select1').dblclick(function(){ //綁定雙擊事件               //擷取全部的選項,刪除並追加給對方               $("option:selected",this).appendTo('#select2'); //追加給對方           });           //雙擊選項           $('#select2').dblclick(function(){               $("option:selected",this).appendTo('#select1');           });       })    </script></head><body><div class="left">    <select name="select1" id="select1" multiple="multiple">        <option value="1">選項1</option>        <option value="2">選項2</option>        <option value="3">選項3</option>        <option value="4">選項4</option>        <option value="5">選項5</option>        <option value="6">選項6</option>        <option value="7">選項7</option>    </select>    <input type="button" value="選中添加到右邊&gt;&gt;" id="buttonl1">    <input type="button" value="全部添加到右邊&gt;&gt;" id="buttonl2"></div><div class="right">    <select name="select2" id="select2" multiple="multiple">        <option value="8">選項8</option>    </select>    <input type="button" value="&lt;&lt;選中刪除到左邊" id="buttonr1">    <input type="button" value="&lt;&lt;全部刪除到左邊" id="buttonr2"></div></body></html>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.