标签:
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="Generator" content="EditPlus®"> | |
| <meta name="Author" content=""> | |
| <meta name="Keywords" content=""> | |
| <meta name="Description" content=""> | |
| <title>Document</title> | |
| <script> | |
| function removeLeft(){ | |
| //找到当前选中的option | |
| var lefeSelect = document.getElementById("left"); | |
| var selectedIndex = lefeSelect.selectedIndex; | |
| var selectedOption = lefeSelect.options[selectedIndex]; | |
| //找到右边的select | |
| var rightSelect = document.getElementById("right"); | |
| rightSelect.add(selectedOption,null); | |
| } | |
| function removeLeftAll(){ | |
| //left的所有option,都移动right | |
| var lefeSelect = document.getElementById("left"); | |
| //找到右边的select | |
| var rightSelect = document.getElementById("right"); | |
| var length =lefeSelect.options.length; | |
| for(var i=0;i<length;i++){ | |
| rightSelect.add(lefeSelect.options[0]); | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <table align="center"> | |
| <tr> | |
| <td> | |
| <select size="10" id="left"> | |
| <option>选项1</option> | |
| <option>选项2</option> | |
| <option>选项3</option> | |
| <option>选项4</option> | |
| <option>选项5</option> | |
| <option>选项6</option> | |
| <option>选项7</option> | |
| <option>选项8</option> | |
| <option>选项9</option> | |
| </select> | |
| </td> | |
| <td> | |
| <input type="button" value="--->" onclick="removeLeft()"/><br/> | |
| <input type="button" value="===>" onclick="removeLeftAll()"/><br/> | |
| </td> | |
| <td> | |
| <select size="10" id="right"> | |
| </select> | |
| </td> | |
| </tr> | |
| </table> | |
| </body> | |
| </html> | |
标签:
原文地址:http://www.cnblogs.com/FG123/p/4445372.html