选中左右侧内容到另一侧
2016-05-13 00:00
495 查看
摘要: 选中左侧内容到右侧,选中右侧内容到左侧
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style type="text/css"> select { width: 100px; height: 140px; } div { width: 130px; float: left; text-align: center; } </style> <script type="text/javascript" src="script/jquery-1.7.2.js"></script> <script type="text/javascript"> $(function(){ $("button:eq(0)").click(function(){ $("select[name=sel01] :selected").each(function(){ $(this).appendTo("select[name=sel02]"); }); }); $("button:eq(1)").click(function(){ $("select[name=sel01] option").each(function(){ $(this).appendTo("select[name=sel02]"); }); }); $("button:eq(2)").click(function(){ $("select[name=sel02] :selected").each(function(){ $(this).appendTo("select[name=sel01]"); }); }); $("button:eq(3)").click(function(){ $("select[name=sel02] option").each(function(){ $(this).appendTo("select[name=sel01]"); }); }); }); </script> </head> <body> <div id="left"> <select multiple="multiple" name="sel01"> <option value="opt01">选项1</option> <option value="opt02">选项2</option> <option value="opt03">选项3</option> <option value="opt04">选项4</option> <option value="opt05">选项5</option> <option value="opt06">选项6</option> <option value="opt07">选项7</option> <option value="opt08">选项8</option> </select> <button>选中添加到右边</button> <button>全部添加到右边</button> </div> <div id="rigth"> <select multiple="multiple" name="sel02"> </select> <button>选中删除到左边</button> <button>全部删除到左边</button> </div> </body> </html> |
相关文章推荐
- JS 获取验证码倒计时
- NSArray、NSDictionary转json字符串
- web前端教程:使用javascript实现多级联动效果
- javascript实例教程:事件委托讲解
- JavaScript不能做什么
- JavaScript继承详解
- JS中event对象的21个常见属性
- js 前加感叹号是什么意思?比如 !function(){}(); 答案在这里
- js中(function(){…})()立即执行函数写法理解
- js中(function(){…})()立即执行函数写法理解
- 关于Json 的泛型转换问题
- js实现树形菜单
- Json序列化和反序列化(Newtonsoft)& 嵌套反序列化
- js实现滑动门效果
- JSP快速入门教程——全十讲
- 从零开始学_JavaScript_系列(15)——js系列<4>(数值、字符串、对象、数组、函数、日期的基本方法)
- js中定时器的使用
- js dom
- JS canvas 表情
- C# JSON字符串序列化与反序列化