JavaScript Select和Option列表元素上下左右移动 时间:2020-05-12 人气:0 作者 马嘉楠 New Document <script language="javascript" > var currentSel = null; function move(){ if(arguments.length==1){ moveUp(arguments[0]); }else if(arguments.length==2){ moveRight(arguments[0],arguments[1]); } } function moveUp(direction){ if(currentSel == null) return; var index = currentSel.selectedIndex; if(direction){//up if(index==0) return; var value = currentSel.options[index-1].value; var text = currentSel.options[index-1].text; currentSel.options[index-1].value = currentSel.options[index].value; currentSel.options[index-1].text = currentSel.options[index].text; currentSel.options[index].value = value; currentSel.options[index].text = text; currentSel.options[index].selected = false; currentSel.options[index-1].selected = true; }else{/https://img.qb5200.com/download-x/down if(index==(currentSel.length-1)) return; var value = currentSel.options[index+1].value; var text = currentSel.options[index+1].text; currentSel.options[index+1].value = currentSel.options[index].value; currentSel.options[index+1].text = currentSel.options[index].text; currentSel.options[index].value = value; currentSel.options[index].text = text; currentSel.options[index].selected = false; currentSel.options[index+1].selected = true; } } function moveRight(src,des){ if(src.selectedIndex==-1){ alert("Please select first!"); return; } for(var i=0;i Java JavaScript C++ HTML CSS .Net [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容