Code
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> No title page </title>
</Head>
<Body>
<Table id = "tb1" border = "1" cellpadding = "3">
<Tr>
<Th> move </th>
<Th> data </th>
<Th> data </th>
<Th> data </th>
</Tr>
<Tr>
<Td> * </td>
<Td> 11111111111 </td>
<Td> sdgergserhserhserh </td>
<Td> awegaw </td>
</Tr>
<Tr>
<Td> * </td>
<Td> 222222222 </td>
<Td> serherwwwwww </td>
<Td> fafafff </td>
</Tr>
<Tr>
<Td> * </td>
<Td> 333333333 </td>
<Td> qqqqqqqwewer </td>
<Td> yukyuk </td>
</Tr>
</Table>
<Script type = "text/javascript">
Var curTr = null;
Var tb1 = document. getElementById ('tb1 ');
Var trs = tb1.getElementsByTagName ('tr ');
Tb1.onselectstart = function (){
If (curTr ){
Document. selection. empty (); return true;
}
};
For (var I = 1; I <trs. length; I ++ ){
Var tds = trs [I]. getElementsByTagName ('td ');
Tds [0]. style. cursor = 'move ';
Tds [0]. onmousedown = function (){
CurTr = this. parentNode;
CurTr. style. backgroundColor = '# eff ';
};
Tds [0]. onmouseover = function (){
If (curTr & curTr! = This. parentNode ){
This. parentNode. swapNode (curTr );
}
}
}
Document. body. onmouseup = function (){
If (curTr ){
CurTr. style. backgroundColor = '';
CurTr = null;
}
};
</Script>
</Body>
</Html>
Note: It is not compatible with firefox and passed the test in IE and chrome.