2-column (TD) Exchange implementation code _javascript techniques in JavaScript Table

Source: Internet
Author: User
Tags generator
<! 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> &LT;TR&GT;&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> &LT;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]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.