<div class="codetitle"> <span><a style="CURSOR: pointer" data="49537" class="copybut" id="copybut49537" onclick="doCopy('code49537')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code49537"> <br><head runat="server"><br> <title>无标题页</title><br> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script><br> <script type="text/javascript"><br> $(document).ready(function(){<br> // 把选择项追加给对方<br> $('#add').click(function(){<br> var options=$('#select1 option:selected');<br> var remove=options.remove();<br> remove.appendTo("#select2");<br> });<br> // 把所有项追加给对方<br> $('#addAll').click(function(){<br> var options=$('#select1 option');<br> var remove=options.remove();<br> remove.appendTo("#select2");<br> });<br> // 把选择项退回给对方<br> $('#remove').click(function(){<br> var options=$('#select2 option:selected');<br> var remove=options.remove();<br> remove.appendTo("#select1");<br> });<br> // 把全部项退回给对方<br> $('#removeAll').click(function(){<br> var options=$('#select2 option');<br> var remove=options.remove();<br> remove.appendTo("#select1");<br> });<br> });<br> </script><br></head><br><body><br> <form id="form1" runat="server"><br> <div id="left"><br> <select multiple="multiple" id="select1" style="width:100px;height:160px"><br> <option>选项1</option><br> <option>选项2</option><br> <option>选项3</option><br> <option>选项4</option><br> <option>选项5</option><br> </select><br> </div><br> <div><br> <span id="add">选中项添加至右边>></span><br /><br> <span id="addAll">全部添加到右边>></span><br> </div><br> <div id="right"><br> <select multiple="multiple" id="select2" style="width:100px;height:160px"></select><br> </div><br> <div><br> <span id="remove"><<选中项还原至左边</span><br /><br> <span id="removeAll"><<全部还原至左边</span><br> </div><br> </form><br></body><br> </div>