2016年7月24日 星期日

jQuery使用Selecter移動Option 內容。

//取得某Select 畫面所有的Option
function optionMoveAdd(移動的Val[]){
$('select[name="selectName"]').find('option').each(function(){
  ///簡易的畫面將所有的OPTION的內容一放到另一個 select  
   for(var i =0;i<obj.length;i++){
     if(obj[i]==$(this).val()){
       $('select[name="sourceSelect"]').append($(this));
      }
   }
 }

 }); }
function optionMovedlect(移動的Val[]){
$('select[name="selectName"]').find('option').each(function(){
  ///簡易的畫面將所有的OPTION的內容一放到另一個 select   
   for(var i =0;i<obj.length;i++){
     if(obj[i]==$(this).val()){
       $('select[name="sourceSelect"]').append($(this));
      }
   }
 }

 });
select 需要增加屬性  multiple="multiple"是可多選的意思  
size = 顯示 ---比數 
    
    
     //或許可加上增加或是刪除扭
    

沒有留言:

張貼留言