最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery 操作兩個(gè)select實(shí)現(xiàn)值之間的互相傳遞

 更新時(shí)間:2014年03月07日 09:04:07   作者:  
本篇文章主要是對(duì)jquery操作兩個(gè)select實(shí)現(xiàn)值之間的互相傳遞進(jìn)行了詳細(xì)的介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
復(fù)制代碼 代碼如下:

function moveToRight(select1,select2)//把選中的移動(dòng)到右邊 sleect1和sleect2分別是下拉列表框的ID
{
 $('#'+select1+' option:selected').each(function(){
  $("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>").appendTo("#"+select2+"");
  $(this).remove();
  $('#'+select2).bind('dblclick',function(){
  moveToLeft(select1,select2);
  });  
 });
}
function moveAllToRight(select1,select2)//把所有的移動(dòng)到右邊
{
 $('#'+select1+' option').each(function(){
  $("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>").appendTo("#"+select2+"");
  $(this).remove();
 });
}
function moveToLeft(select1,select2)//把選中的移動(dòng)到左邊
{
 $('#'+select2+' option:selected').each(function(){
  $("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>").appendTo("#"+select1+"");
  $(this).remove();
 });
}
function moveAllToLeft(select1,select2)//把所有的移動(dòng)到左邊
{
 $('#'+select2+' option').each(function(){
  $("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>").appendTo("#"+select1+"");
  $(this).remove();
 });
}

如果要雙擊select中的某一個(gè)option就把當(dāng)前值傳到另一個(gè)select需要bind一個(gè)select 事件 如下即可
復(fù)制代碼 代碼如下:

$('#sel2').bind('dblclick',function(){//給下拉框綁定雙擊事件
     moveToRight('sel2','sel3');
    });
    $('#sel3').bind('dblclick',function(){
     moveToLeft('sel2','sel3');
    }); 

相關(guān)文章

最新評(píng)論

仁寿县| 和顺县| 枞阳县| 孟村| 宣汉县| 睢宁县| 毕节市| 福海县| 尤溪县| 三台县| 山丹县| 凌源市| 星子县| 鄢陵县| 黄石市| 祁门县| 抚州市| 凤台县| 寿宁县| 赤峰市| 武功县| 湟中县| 隆子县| 曲靖市| 原阳县| 固安县| 安新县| 罗城| 临桂县| 鱼台县| 万安县| 康平县| 天镇县| 白银市| 云龙县| 卢氏县| 湟源县| 昌乐县| 固原市| 宜黄县| 新蔡县|