<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> New Document &L t;/title> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "Majianan" > <META N Ame= "Keywords" content= "" > <meta name= "Description" content= "" > <script type= "Text/javascript" ><!- -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); Function swap () {var T1 = document.getElementById ("T1"). Value; var t2 = document.getElementById ("t2"). Value; SwapNode (document.getElementById (T1), document.getElementById (T2)); }//--></script> </HEAD> <BODY> <table> <tr> <td id= ' a ' >[a]</td> < TD id= ' B ' >[b]</td> <td id= ' C ' >[c]</td> <td id= ' d ' >[d]</td> <td id= ' e ' >[e]</td> </tr> </table> <TR>&L T;td><input id= ' t1 ' type= "text" value= "a" ></td></tr> <tr><td><input id= ' T2 ' type = "text" value= "B" ></td></tr> <tr><td><input type= "button" value= "swap" onclick= "swap ( ) "></td></tr> </BODY> </HTML>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The above format, more strange, I used JS slightly changed, the text box is to be converted to the index, can not easily lose.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <HEAD> <meta content=" text/html;charset=gb2312 " http-equiv=content-type> <TITLE> New Document </TITLE> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "Majianan" > <meta name= "Keywords" content= "" > <meta name= "Description" Content= "" > <script type= "text/javascript" ><!--function SwapNode (node1,node2) {var _parent=node1.paren Tnode; 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); Function swap () {var T1 = document.getElementById ("T1"). Value; var t2 = document.getElementById ("t2"). Value; SwapNode (document.getElementById (T1), document.getElementById (T2)); }//--></script> </HEAD> <BODY> <table> <tr> <td id= ' a ' >[a]</td> <TD id= ' B ' >[b]</td> <td id= ' C ' >[c]</td> <td id= ' d ' >[d]</td> <td id= ' e ' >[e] </td> </tr> </table> <tr><td><input id= ' t1 ' type= "text" value= "a" ></td> </tr> <tr><td><input id= ' T2 ' type= "text" value= "B" ></td></tr> <tr><td ><input type= "button" value= "swap" onclick= "swap ()" ></td></tr> </BODY> </HTML>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]