运行效果图如下:
完整代码如下:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> <!-- BODY { font-family:"Courier"; font-size: 12px; margin:0px auto; /*不显示 横纵向 滚动条*/ overflow-x:no; overflow-y:no; background-color: #B8D3F4; } td { font-size:12px; } .default_input { border:1px solid #666666; height:18px; font-size:12px; } .default_input2 { border:1px solid #666666; height:18px; font-size:12px; } .nowrite_input { border:1px solid #849EB5; height:18px; font-size:12px; background-color:#EBEAE7; color: #9E9A9E; } .default_list { font-size:12px; border:1px solid #849EB5; } .default_textarea { font-size:12px; border:1px solid #849EB5; } .nowrite_textarea { border:1px solid #849EB5; font-size:12px; background-color:#EBEAE7; color: #9E9A9E; } .wordtd5 { font-size: 12px; text-align: center; vertical-align:top; padding-top: 6px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; background-color: #b8c4f4; } .wordtd { font-size: 12px; text-align: left; vertical-align:top; padding-top: 6px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; background-color: #b8c4f4; } .wordtd_1 { font-size: 12px; vertical-align:top; padding-top: 6px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; background-color: #516CD6; color:#fff; } .wordtd_2{ font-size: 12px; text-align: right; vertical-align:top; padding-top: 6px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; background-color: #64BDF9; } .wordtd_3{ font-size: 12px; text-align: right; vertical-align:top; padding-top: 6px; padding-right: 5px; padding-bottom: 3px; padding-left: 5px; background-color: #F1DD34; } .inputtd { font-size:12px; vertical-align:top; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; } .inputtd2 { text-align: center; font-size:12px; vertical-align:top; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; } .tablebg { font-size:12px; } .tb{ border-collapse: collapse; border: 1px outset #999999; background-color: #FFFFFF; } .td2{line-height:22px; text-align:center; background-color:#F6F6F6;} .td3{background-color:#B8D3F4; text-align:center; line-height:20px;} .td4{background-color:#F6F6F6;line-height:20px;} .td5{border:#000000 solid; border-right-width:0px; border-left-width:0px; border-top-width:0px; border-bottom-width:1px;} .tb td{ font-size: 12px; border: 2px groove #ffffff; } .noborder { border: none; } .button { /*ridge: 根据border-color的值画菱形边框 */ border: 1px ridge #ffffff; /*行间距 (上下)大小 */ line-height:18px; height: 20px; width: 45px; padding-top: 0px; background:#CBDAF7; color:#000000; font-size: 9pt; font-family:"Courier"; } .textarea { font-family: Arial, Helvetica, sans-serif, "??"; font-size: 9pt; color: #000000; border-bottom-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #000000; background-color:transparent; text-align: left } --> </style> <script type="text/javascript" src="https://www.jb51.net/jquery-1.4.2.min.js"></script> </head> <body> <div> <table cellpadding="0" cellspacing="0"> <tr> <td> <!--multiple="multiple" 能同时选择多个 size="10" 确定下拉选的长度--> <select size="10" multiple="multiple"> <option value="选项1">选项1</option> <option value="选项2">选项2</option> <option value="选项3">选项3</option> <option value="选项4">选项4</option> <option value="选项5">选项5</option> <option value="选项6">选项6</option> <option value="选项7">选项7</option> <option value="选项8">选项8</option> </select> </td> <td valign="middle"> <input type="button" value="-->" /> <input type="button" value="==>" /> <input type="button" value="<--" /> <input type="button" value="<==" /> </td> <td> <select size="10" multiple="multiple"> <option value="选项9">选项9</option> </select> </td> </tr> </table> </div> </body> <script type="text/javascript"> /**<input type="button" value="-->" /> */ /** * <select size="10" multiple="multiple"> <option value="选项1">选项1</option> <option value="选项2">选项2</option> <option value="选项3">选项3</option> <option value="选项4">选项4</option> <option value="选项5">选项5</option> <option value="选项6">选项6</option> <option value="选项7">选项7</option> <option value="选项8">选项8</option> </select> */ $().ready(function() { $("#add").click(function(){ $("#first option:selected").appendTo($("#second")); }); $("#add_all").click(function() { $("#first option").appendTo($("#second")); }); $("#first").dblclick(function(){ $("#first option:selected").appendTo($("#second")); }); $("#remove").click(function() { $("#second option:selected").appendTo($("#first")); }); $("#remove_all").click(function() { $("#second option").appendTo($("#first")); }); }); </script> </html>