- <table width="200" border="1">
- <tbody>
- <tr>
- <td width="25%">1</td>
- <td width="25%">11</td>
- <td width="25%"><a href="javascript:void(0)" onclick="moveUp(this)">上移</a></td>
- <td width="25%"><a href="javascript:void(0)" onclick="moveDown(this)">下移</a></td>
- </tr>
- <tr>
- <td>2</td>
- <td>22</td>
- <td><a href="javascript:void(0)" onclick="moveUp(this)">上移</a></td>
- <td><a href="javascript:void(0)" onclick="moveDown(this)">下移</a></td>
- </tr>
- <tr>
- <td>3</td>
- <td>33</td>
- <td><a href="javascript:void(0)" onclick="moveUp(this)">上移</a></td>
- <td><a href="javascript:void(0)" onclick="moveDown(this)">下移</a></td>
- </tr>
- <tr>
- <td>4</td>
- <td>44</td>
- <td><a href="javascript:void(0)" onclick="moveUp(this)">上移</a></td>
- <td><a href="javascript:void(0)" onclick="moveDown(this)">下移</a></td>
- </tr>
- <tr>
- <td>5</td>
- <td>55</td>
- <td><a href="javascript:void(0)" onclick="moveUp(this)">上移</a></td>
- <td><a href="javascript:void(0)" onclick="moveDown(this)">下移</a></td>
- </tr>
- </tbody>
- </table>
-
- <script type="text/javascript">
- <!--
- function moveUp(_a){
- var _row = _a.parentNode.parentNode;
-
- var _node = _row.previousSibling;
- while(_node && _node.nodeType != 1){
- _node = _node.previousSibling;
- }
- if(_node){
- swapNode(_row,_node);
- }
- }
-
- function moveDown(_a){
- var _row = _a.parentNode.parentNode;
-
- var _node = _row.nextSibling;
- while(_node && _node.nodeType != 1){
- _node = _node.nextSibling;
- }
- if(_node){
- swapNode(_row,_node);
- }
- }
-
- function swapNode(node1,node2){
-
- var _parent = node1.parentNode;
-
- var _t1 = node1.nextSibling;
- var _t2 = node2.nextSibling;
-
- if(_t1)_parent.insertBefore(node2,_t1);
- else _parent.appendChild(node2);
-
- if(_t2)_parent.insertBefore(node1,_t2);
- else _parent.appendChild(node1);
- }
-
- </script>