当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


HTML DOM Table 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>

输出

单击 “Create Footer” 按钮为表格创建页脚。

相关用法


注:本文由纯净天空筛选整理自AmitDiwan大神的英文原创作品 HTML DOM Table createTFoot() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。