HTML DOM createTFoot() 方法

定义和用法

createTFoot() 方法用于在表格中获取或创建 <tfoot> 元素。

语法

  1. tableObject.createTFoot()

返回值

返回一个 TableSection,表示该表的 <tfoot> 元素。如果该表格已经有了脚注,则返回它。如果该表没有脚注,则创建一个新的空 <tfoot> 元素,把它插入表格,并返回它。

实例

下面的例子为表格创建了一个脚注:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function createCaption()
  5. {
  6. var x=document.getElementById('myTable').createTFoot()
  7. x.innerHTML="My table foot"
  8. }
  9. </script>
  10. </head>
  11. <body>
  12.  
  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. </table>
  23. <br />
  24. <input type="button" onclick="createCaption()"
  25. value="Create caption">
  26.  
  27. </body>
  28. </html>