♀表格行之间的拖拽,请高手指教!♂
本人模仿JK的表格行之间的拖拽代码,写了一个自己的表格行之间的拖拽,只是将拖拽事件放到了表格行的一个单元格中,结果就不能运行了,不知道为什么,请高手指教!
我修改的:
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> JK:支持民族工业,尽量少买X货 </title>
<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>
</head>
<body >
<TABLE id= "tbl " WIDTH= "300 " BORDER= "1 " >
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' > <td bgcolor= "gray " width= "20px " onmousedown= 'MouseDownToMove(this.parentElement) ' onmousemove= 'MouseMoveToMove(this.parentElement) '