jQuery 实现左右两侧菜单添加、移除功能
程序员文章站
2022-07-06 10:52:07
效果图:
js代码
function toright(l, r, v) {
$("#" + l + " option:selected")....
效果图:
js代码
function toright(l, r, v) { $("#" + l + " option:selected").appendto("#" + r); $("#" + l + " option:selected").remove(); var str = $("#" + l + " option").map(function () { return $(this).val(); }).get().join(", ") $("#" + v).val(str); } function alltoright(l, r, v) { $("#" + l + " option").appendto("#" + r); $("#" + l + " option").remove(); var str = $("#" + l + " option").map(function () { return $(this).val(); }).get().join(", ") $("#" + v).val(str); } function toleft(l, r, v) { $("#" + r + " option:selected").appendto("#" + l); $("#" + r + " option:selected").remove(); var str = $("#" + l + " option").map(function () { return $(this).val(); }).get().join(", ") $("#" + v).val(str); } function alltoleft(l, r, v) { $("#" + r + " option").appendto("#" + l); $("#" + r + " option").remove(); var str = $("#" + l + " option").map(function () { return $(this).val(); }).get().join(", ") $("#" + v).val(str); }
html代码
<div class="easyui-layout" data-options="fit:true"> <div data-options="region:'west',split:false" style="width:40%;padding:0px"> <h3 style="padding:5px; border-bottom:1px solid #dddddd;">::已授权权限::</h3> <div data-options="region:'center'" style="padding:3px; height:215px;" border="false"> <select multiple="multiple" id="menufunc" style="width:100%;height:100%"> </select> <input type="hidden" name="func" id="func" value="" /> </div> </div> <div data-options="region:'east'" style="width:40%;padding:0px"> <h3 style="padding:5px;border-bottom:1px solid #dddddd;">::未授权权限::</h3> <div data-options="region:'center'" style="padding:3px; height:215px;" border="false"> <select multiple="multiple" id="menufuncbase" style="width:100%;height:100%"> </select> </div> </div> <div data-options="region:'center'" style="padding:40px; width: 197px; height:230px;line-height:40px; text-align:center;"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="button button-primary button-rounded button-small" onclick="toleft('menufunc','menufuncbase','func')" > < </a><br /> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="button button-primary button-rounded button-small" onclick="alltoleft('menufunc','menufuncbase','func')" ><<</a><br /> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="button button-caution button-rounded button-small" onclick="toright('menufunc','menufuncbase','func')" > > </a><br /> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="button button-caution button-rounded button-small" onclick="alltoright('menufunc','menufuncbase','func')">>></a><br /> </div> </div>
总结
以上所述是小编给大家介绍的jquery 实现左右两侧菜单添加、移除功能,希望对大家有所帮助
上一篇: php支付宝APP支付功能