日期:2014-05-16 浏览次数:20377 次
function move() { var sel = document.getElementById("List"); if (sel.options.length > 0 && sel.selectedIndex != -1) { var node = sel.options[sel.selectedIndex]; var nextNode; if (sel.selectedIndex == 0) nextNode = null; else nextNode = sel.options[sel.selectedIndex - 1]; if (nextNode) node.swapNode(nextNode); //移动 } }
<select size="2" style="height: 203px; width: 309px" id="List" multiple="multiple"> <option>a</option> <option>b</option> </select> <input type="button" value="up" onclick="move()">