更改表元横跨的列数

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeColSpan()
  5. {
  6. document.getElementById("td1").colSpan="2";
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. <table border="1">
  13. <tr>
  14. <th></th>
  15. <th></th>
  16. </tr>
  17. <tr>
  18. <td id="td1">John</td>
  19. <td id="td2">Adams</td>
  20. </tr>
  21. </table>
  22. <br />
  23. <input type="button" onclick=changeColSpan() value="改变 colspan" />
  24.  
  25. </body>
  26. </html>