jquery的综合应用2(select里option元素的移动)

下面演示了两个下拉框元素的移动

<script type="text/javascript">
  //<input name="add"  id="add" type="button" class="button" value="-->" />
  $("#add").click(function(){
   $("#first option:selected").appendTo($("#second"));
  });
  
  //<input name="add_all" id="add_all" type="button" class="button" value="==>" />
  $("#add_all").click(function(){
   $("#first option").appendTo($("#second"));
  });
  
  
  //<input name="remove"  id="remove" type="button" class="button" value="&lt;--" />
  $("#remove").click(function(){
   $("#second option:selected").appendTo($("#first"));
  });
  
  
  //<input name="remove_all" id="remove_all" type="button" class="button" value="&lt;==" />
  $("#remove_all").click(function(){
   $("#second option").appendTo($("#first"));
  });
  
  //双击
  $("#first").dblclick(function(){
   $("#first option:selected").appendTo($("#second"));
  });
  
  $("#second").dblclick(function(){
   $("#second option:selected").appendTo($("#first"));
  });
 
  </script>

posted @ 2013-10-05 21:32  sadan  阅读(237)  评论(0编辑  收藏  举报