《2022年用鼠标拖动表格进行排序CSSHTML教程.docx》由会员分享,可在线阅读,更多相关《2022年用鼠标拖动表格进行排序CSSHTML教程.docx(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2022年用鼠标拖动表格进行排序CSSHTML教程<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;
2、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
3、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);}</s
4、cript>用鼠标移动TR<br><TABLE WIDTH=300 BORDER=1 ><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD bgcolor=blue>0</TD><TD>0</TD><TD>0</TD>&l
5、t;/TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD bgcolor=black>1</TD><TD>1</TD><TD>1</TD></TR><TR bgcolor=#ffffff style=height:25;p
6、osition:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD bgcolor=red>2</TD><TD>2</TD><TD>2</TD></TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this)
7、 onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD>3</TD><TD>3</TD><TD>3</TD></TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this
8、);><TD>4</TD><TD>4</TD><TD>4</TD></TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD>5</TD><TD>5</TD><TD>5&l
9、t;/TD></TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD>6</TD><TD>6</TD><TD>6</TD></TR><TR bgcolor=#ffffff style=height:25;position:relative; onmousedown=MouseDownToMove(this) onmousemove=MouseMoveToMove(this) onmouseup=MouseUpToMove(this);><TD>7</TD><TD>7</TD><TD>7</TD></TR></script></TABLE>