JavaScript Select 와 Option 목록 요소 상하 좌우 이동

저자 마 가 난새 문서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{//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
[Ctrl+A 전체 선택:외부 Js 를 도입 하려 면 페이지 를 새로 고침 해 야 실행 할 수 있 습 니 다.]

좋은 웹페이지 즐겨찾기