自己写的jQuery 左右选择框,大家多多指教!
Ui框架分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" 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="sel_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"> <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>
相关推荐
VitaLemon 2020-10-17
北京老苏 2020-08-17
一像素 2020-08-16
yfisaboy 2020-07-28
preserve log:勾选,页面发生跳转,接口不丢失;;Disable cache:不使用缓存,勾选,拿服务器的缓存;不勾选,用本地缓存;;All那列,表示浏览器的请求类型,对应下面的列type;
baynkbtg 2020-07-05
dingqinghu 2020-06-16
deadgrape 2020-06-09
liujia 2020-06-02
牵手白首 2020-06-02
kikaylee 2020-05-31
MaureenChen 2020-05-25
delmarks 2020-05-17
王磊的程序员之路 2020-05-15
STPace 2020-05-07
singer 2020-05-07
e度空间 2020-04-30
furongwei 2020-04-25