document.write('
解析:
例如:<html>
 <head>
 <script>
 function subOnClick(){
 var text1=document.getElementById("txt1").value;
// 取 txt1 文本
 var text2=document.getElementById("txt2").value;
// 取 txt2 文本
 // 开始互换
 document.getElementById("txt1").value=text2;
 document.getElementById("txt2").value=text1;
 }
 window.onload=function(){
 document.getElementById("submitBtn1").onclick=
 subOnClick;
 document.getElementById("submitBtn2").onclick=
 subOnClick;
 }
 </script>
 </head>
 <body>
 <input type="text" value="12345666" id="txt1" />
 <input type="submit" id="submitBtn1" />
 <input type="text" value="12345222" id="txt2" />
 <input type="submit" id="submitBtn2" />
 </body>

 </html> 

');