jQuery實(shí)現(xiàn)Select左右復(fù)制移動(dòng)內(nèi)容
引入的文件為<script type="text/javascript" src="jquery-1.10.2.js"></script>
雙擊也可以移動(dòng)
[1].[代碼]
<script type="text/javascript">
$(function(){
//移到右邊
$("#add").click(function(){
//獲取選中的選項(xiàng),刪除并追加給對(duì)方
$("#select1 option:selected").appendTo("#select2");
});
//移到左邊
$("#remove").click(function(){
$("#select2 option:selected").appendTo("#select1");
});
//全部移到右邊
$("#add_all").click(function(){
//獲取全部的選項(xiàng),刪除并追加給對(duì)放
$("#select1 option").appendTo("#select2");
});
//全部移到左邊
$("#remove_all").click(function(){
$("#select2 option").appendTo("#select1");
});
//雙擊選項(xiàng)
$("#select1").dblclick(function(){//綁定雙擊事件
//獲取全部的選項(xiàng),刪除并追加給對(duì)方
$("option:selected",this).appendTo("#select2");//追加給對(duì)方
});
//雙擊選項(xiàng)
$("#select2").dblclick(function(){
$("option:selected",this).appendTo("#select1");
});
})
</script>
[2].[代碼]
<body> <h1>Select JQuery 實(shí)現(xiàn)左右復(fù)制移動(dòng)內(nèi)容</h1> <div style="width:500px;"> <div class="centent" style="float:left;"> <select multiple="multiple" id="select1" style="width:130px;height:160px;"> <option value="1">選項(xiàng)1</option> <option value="2">選項(xiàng)2</option> <option value="3">選項(xiàng)3</option> <option value="4">選項(xiàng)4</option> <option value="5">選項(xiàng)5</option> <option value="6">選項(xiàng)6</option> <option value="7">選項(xiàng)7</option> <option value="8">選項(xiàng)8</option> </select> <div> <button id="add" >選中添加到右邊>></button><br> <button id="add_all" >全部添加到右邊>></button> </div> </div> <div class="centent" style="padding-left:160px;"> <select multiple="multiple" id="select2" style="width: 130px;height:160px;"> </select> <div> <button id="remove"><<選中刪除到左邊</button><br> <button id="remove_all"><<全部刪除到左邊</button> </div> </div> </div> </body>
[3].[圖片]

[4].[圖片]

以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)Select左右移動(dòng)復(fù)制內(nèi)容,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
基于jquery實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)效果
這篇文章主要介紹了基于jquery實(shí)現(xiàn)省市區(qū)三級(jí)聯(lián)動(dòng)效果,需要的朋友可以參考下2015-12-12
如何用input標(biāo)簽和jquery實(shí)現(xiàn)多圖片的上傳和回顯功能
本文通過圖文并茂的形式給大家介紹了如何用input標(biāo)簽和jquery實(shí)現(xiàn)多圖片的上傳和回顯功能,需要的朋友可以參考下2018-05-05
基于jQuey實(shí)現(xiàn)鼠標(biāo)滑過變色(整行變色)
相信大家在一些網(wǎng)站都看到過這種效果吧,當(dāng)鼠標(biāo)放在新聞列表一行的時(shí)候,整行就會(huì)變色,雖然使用CSS也能夠?qū)崿F(xiàn)此種功能,但是由于眾多瀏覽器版本對(duì)于CSS3并沒有良好的支持,所以在當(dāng)前情況下,使用jQuery實(shí)現(xiàn)此種功能是一個(gè)不錯(cuò)的選擇2015-12-12
jQuery post數(shù)據(jù)至ashx實(shí)例詳解
這篇文章主要介紹了jQuery post數(shù)據(jù)至ashx實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2016-11-11
jquery表單對(duì)象屬性過濾選擇器實(shí)例分析
這篇文章主要介紹了jquery表單對(duì)象屬性過濾選擇器,實(shí)例分析了jQuery選擇器的相關(guān)使用技巧,需要的朋友可以參考下2015-05-05

