jquery select 删除 增加节点
2014-03-20 21:09
483 查看
$(document).ready(function() { var sleft = $('#sleft'); var sright = $('#sright'); var bleft = $('#bleft'); var bright = $('#bright'); bleft.bind('click', function() { if (sleft.find("option:selected").text() != "") { if ($('#sleft option').size() <= 0) { $('#sleft').attr("disabled", true); } else { if ($('#sleft option:selected').length >1) { $('#sleft option:selected').each(function(i, data) { sright.append(data); }); } else{ var a = sleft.find("option:selected").text(); var b = sleft.find("option:selected").val(); sleft.find("option:selected").remove(); sright.append("<option value="+b+">" + a + "</option>"); } } } }); bright.bind('click', function() { if (sright.find("option:selected").text() != "") { if ($('#sright option').size() <= 0) { $('#sright').attr("disabled", true); } else { if (('#sright option:selected').length >1) { $('#sright option:selected').each(function(i, data) { sleft.append(data); }); } else{ var c = sright.find("option:selected").text(); var d = sright.find("option:selected").val(); sright.find("option:selected").remove(); sleft.append("<option value="+c+">" + d + "</option>"); } } } }); });
<div> <div style="float: left;"> <select multiple="multiple" style="width:70px;" id="sleft"> <option value="1">1</option> <option value="2">2</option> </select> </div> <div style="float: left"> <div> <input id="bleft" type="button" style="float: left" value=">>" /> </div> <div> <input id="bright" type="button" style="float: left" value="<<" /> </div> </div> <div style="float: left"> <select multiple="multiple" id="sright" style="width:70px;"> <option value="3">3</option> <option value="4">4</option> </select> </div> </div>
相关文章推荐
- jquery操作select(增加,删除,清空)
- jQuery操作select下拉框(增加,删除,修改)
- (转)Jquery对select(增加、删除、清空)以及设置固定某值选定
- JQuery对Table进行全选反选 增加节点 删除节点
- jquery操作select(增加,删除,清空)
- JQuery给元素添加/删除节点比如select
- JQuery给select添加/删除节点的实现代码
- jquery操作select(增加,删除,清空)
- JQuery给select添加/删除节点
- jQuery 增加 删除 修改select option .
- jquery操作select(增加,删除,清空)
- jquery操作select(增加,删除,清空)
- jquery操作select(增加,删除,清空)
- tinyxml使用:创建XML,遍历打印xml文件 select操作,获取单个节点值,删除节点操作,修改节点操作,增加节点操作
- jquery操作select 增加,删除,清空
- (转)jquery操作select(增加,删除,清空)
- JQuery给select添加/删除节点的实现代码
- jQuery 增加 删除 修改select option .
- jquery操作select(增加,删除,清空)
- jQuery编辑Select标签 增加修改删除 选