1 <body> 2 <table id="table1"> 3 <tr> 4 <td>第一个单元格</td> 5 <td>第二个单元格</td> 6 </tr> 7 </table> 8 <input type="button" value="改变" onclick="change()"> 9 <script> 10 function change(){ 11 var x,y; 12 x=document.getElementById(‘table1‘).rows[0].cells[0].innerhtml; 13 y=document.getElementById(‘table1‘).rows[0].cells[1].innerHTML; 14 document.getElementById(‘table1‘).rows[0].cells[1].innerHTML=x; 15 document.getElementById(‘table1‘).rows[0].cells[0].innerHTML=y; 16 } 17 </script> 18 </body>