鼠标拖动表格进行排序

鼠标拖动表格进行排序

<script language="javascript"> var beginMoving=false; function MouseDownToMove(obj){ obj.style.zIndex=1; obj.mouseDownY=event.clientY; obj.mouseDownX=event.clientX; beginMoving=true; obj.setCapture(); } function MouseMoveToMove(obj){ if(!beginMoving) return false; obj.style.top = (event.clientY-obj.mouseDownY); obj.style.left = (event.clientX-obj.mouseDownX); } function MouseUpToMove(obj){ if(!beginMoving) return false; obj.releaseCapture(); obj.style.top=0; obj.style.left=0; obj.style.zIndex=0; beginMoving=false; var tempTop=event.clientY-obj.mouseDownY; var tempRowIndex=(tempTop-tempTop%25)/25; if(tempRowIndex+obj.rowIndex <0 )tempRowIndex=-1; else tempRowIndex=tempRowIndex+obj.rowIndex; if(tempRowIndex >= obj.parentElement.rows.length-1) tempRowIndex = obj.parentElement.rows.length -1; obj.parentElement.moveRow(obj.rowIndex,tempRowIndex); } </script>

4
2
0
1
3


加入如下代码到body区域

<script language="JavaScript"> <!-- function closeclk() { another=close(); } //--> </script>
来自:http://www.yourhand.cn/special/jsjq/t/table/table2.htm

你可能感兴趣的:(排序)