jquery made select list bi-directional, compatibility is certainly good, need friends can learn under
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> New Document &L t;/title> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta NAME= "Key Words "content=" "> <meta name=" Description "content=" "> <script type=" text/javascript "src=" http://
Code.jquery.com/jquery-1.4.2.min.js "></script> <style> sel{width:150px;height:200px;}
. btn{width:50px;font-weight:bold;font-size:14px;} </style> </HEAD> <BODY> <table> <tr> <td> <select multiple class= "sel" id= "s
El_left "> <option value=" a ">aaaaaaaaaaa</option> <option value=" B ">bbbbbbbbbbb</option> <option value= "C" >ccccccccccc</option> <option value= "D" >ddddddddddd</option> <option Value= "E" >eeeeeeeeeee</option> </select> </td> <td> <p><button class= "btn" id= " Btn_1 ">>> </button></p> <p><button class= "btn" id= "Btn_2" >></button></p> <p><button class= "btn" id= "Btn_3" ><</button></p> <p><button class= "btn" id= "BTN" _4 "><<</button></p> </td> <td> <select multiple class=" sel id= "Sel_right" > &L T;option value= "F" >fffffffffff</option> </select> </td> </tr> </table> </body>
;
<script> $ (function () {$ (#sel_left, #sel_right). Bind ("Change", checkbtn);
$ ("#btn_1, #btn_2, #btn_3, #btn_4"). Bind ("click", Clickbtn);
CHECKBTN ();
}); function checkbtn () {jquery ("#sel_left >option"). Length > 0 jquery ("#btn_1"). Removeattr ("Disabled"): jquery ("#
Btn_1 "). attr (" Disabled "," disabled "); JQuery ("#sel_left option:selected"). length > 0?
jquery ("#btn_2"). Removeattr ("Disabled"): jquery ("#btn_2"). attr ("Disabled", "disabled"); JQuery ("#sel_right option:selected"). length > 0? JQuery ("#bTn_3 "). Removeattr (" Disabled "): JQuery (" #btn_3 "). attr (" Disabled "," disabled "); JQuery ("#sel_right >option"). length > 0?
jquery ("#btn_4"). Removeattr ("Disabled"): jquery ("#btn_4"). attr ("Disabled", "disabled");
function Clickbtn (e) {if ("btn_1" = e.target.id) {jQuery ("#sel_left >option"). Appendto ("#sel_right");
}else if ("btn_2" = = e.target.id) {jQuery ("#sel_left option:selected"). Appendto ("#sel_right");
}else if ("btn_3" = = e.target.id) {jQuery ("#sel_right option:selected"). Appendto ("#sel_left");
}else if ("btn_4" = = e.target.id) {jQuery ("#sel_right >option"). Appendto ("#sel_left");
} checkbtn (); } </script> </HTML>