드롭다운 상자 적용

2523 단어
        $(function(){
            $('#add').click(function(){
                var $options = $('#select1 option:selected');
                $options.appendTo("#select2");
            });
            $('#remove').click(function(){
                var $options = $('#select2 option:selected');
                $options.appendTo("#select1");
            });
            $('#add_all').click(function(){
                var $options = $('#select1 option');
                $options.appendTo("#select2");
            });
            $('#remove_all').click(function(){
                var $options = $('#select2 option');
                $options.appendTo("#select1");
            });
            $('#select1').dblclick(function(){
               var $options = $("option:selected",this); // 
                $options.appendTo('#select2');
            });
            $('#select2').dblclick(function(){
                var $options = $("option:selected",this); // 
                $options.appendTo('#select1');
            });
        });
   <div style="width: 250px">
   <div class="content" style="float: left">
       <select multiple id="select1" style="width: 100px;height: 160px;">
           <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>
           <option value="8"> 8</option>
       </select>
       <div>
           <span id="add"> &gt;&gt;</span><br>
           <span id="add_all"> &gt;&gt;</span>
       </div>
   </div>
   <div style="float: right;">
       <select multiple id="select2" style="width: 100px;height: 160px;">
       </select>
       <div>
           <span id="remove">&lt;&lt; </span><br>
           <span id="remove_all">&lt;&lt; </span>
       </div>
   </div>
</div>

좋은 웹페이지 즐겨찾기