更改表格单元格中的内容

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeContent()
  5. {
  6. var x=document.getElementById('myTable').rows[0].cells
  7. x[0].innerHTML="新的内容"
  8. }
  9. </script>
  10. </head>
  11.  
  12. <body>
  13. <table id="myTable" border="1">
  14. <tr>
  15. <td>Row1 cell1</td>
  16. <td>Row1 cell2</td>
  17. </tr>
  18. <tr>
  19. <td>Row2 cell1</td>
  20. <td>Row2 cell2</td>
  21. </tr>
  22. <tr>
  23. <td>Row3 cell1</td>
  24. <td>Row3 cell2</td>
  25. </tr>
  26. </table>
  27. <form>
  28. <input type="button" onclick="changeContent()" value="改变内容">
  29. </form>
  30. </body>
  31.  
  32. </html>