HTML DOM 表格 createTFoot() 方法


HTML DOM 表格 createTFoot() 方法生成一個空的 <tfoot> 元素並將其新增到 HTML 文件的表格中。

語法

以下是語法 −

object.createTFoot()

我們來看一個 HTML DOM 表格 createTFoot() 方法的示例 −

示例

 演示例項

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      background: lightblue;
      height: 100vh;
      text-align: center;
   }
   table {
      margin: 2rem auto;
   }
   caption {
      color: #db133a;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem auto;
   }
   .show {
      font-size: 1.2rem;
   }
</style>
<body>
<h1>DOM Table createTFoot() Method Demo</h1>
<table border="2">
<tr>
<td>Name</td>
<td>Roll No.</td>
</tr>
<tr>
<td>John</td>
<td>071717</td>
</tr>
<tr>
<td>Jane</td>
<td>031717</td>
</tr>
</table>
<button onclick="create()" class="btn">Create Footer</button>
<script>
   function create() {
      var tableFooter = document.querySelector('table').createTFoot();
      tableFooter.innerHTML = "This is table footer";
   }
</script>
</body>
</html>

輸出

單擊“建立頁尾”按鈕為表格建立頁尾。

更新時間: 19-9 月-2019

64 次瀏覽

助力 職業起步

完成課程以獲得認證

開始
廣告
© . All rights reserved.