YouTip LogoYouTip

Met Table Createthead

HTML DOM Table createTHead() Method function createTHead(){ var x=document.getElementById("myTable"); if (!x.tHead){ var header=x.createTHead(); var row=header.insertRow(0); var cell=row.insertCell(0); cell.innerHTML="This is a table header"; } } function deleteTHead(){ document.getElementById("myTable").deleteTHead(); }

-- Learn not just technology, but also dreams!

JavaScript Reference Manual

Overview

  • JavaScript Objects
  • JavaScript Array Object
  • JavaScript Boolean Object
  • JavaScript Date Object
  • JavaScript Math Object
  • JavaScript Number Object
  • JavaScript String Object
  • JavaScript RegExp Object
  • JavaScript Global Properties/Functions
  • JavaScript Operators
  • JavaScript Error

Browser Objects

  • Window Object
  • Navigator Object
  • Screen Object
  • History Object
  • Location Object
  • Storage Objects

DOM Objects

  • HTML DOM Document Object
  • HTML DOM Element Object
  • HTML DOM Attribute Object
  • HTML DOM Event Object
  • HTML DOM Console Object
  • CSSStyleDeclaration Object
  • DOM HTMLCollection

HTML Objects

  • <a>
  • <area>
  • <audio>
  • <base>
  • <blockquote>
  • <body>
  • <button>
  • <canvas>
  • <col>
  • <colgroup>
  • <datalist>
  • <del>
  • <details>
  • <dialog>
  • <embed>
  • <fieldset>
  • <form>
  • <iframe>
  • <frameset>
  • <img>
  • <ins>
  • <input> - button
  • <input> - checkbox
  • <input> - color
  • <input> - date
  • <input> - datetime
  • <input> - datetime-local
  • <input> - email
  • <input> - file
  • <input> - hidden
  • <input> - image
  • <input> - month
  • <input> - number
  • <input> - range
  • <input> - password
  • <input> - radio
  • <input> - reset
  • <input> - search
  • <input> - submit
  • <input> - text
  • <input> - time
  • <input> - url
  • <input> - week
  • <keygen>
  • <link>
  • <label>
  • <legend>
  • <li>
  • <map>
  • <menu>
  • <menuItem>
  • <meta>
  • <meter>
  • <object>
  • <ol>
  • <optgroup>
  • <option>
  • <param>
  • <progress>
  • <q>
  • <script>
  • <select>
  • <source>
  • <style>
  • <table>
  • <td>
  • <th>
  • <tr>
  • <textarea>
  • <title>
  • <time>
  • <track>
  • <video>

HTML DOM Style Object

HTML DOM td / th Object

In-depth Exploration

  • Development Tools
  • Software
  • Scripting Languages
  • Web Service
  • Network Services
  • Programming
  • Programming Languages
  • Web Design and Development
  • Scripts
  • Computer Science

Table createTHead() Method

Table Object

Definition and Usage

The createTHead() method is used to get or create a <thead> element in a table.

Note: If the thead element already exists in the table, the createTHead() method returns the existing value and does not return a new <thead> element.

Tip: To remove the thead element from the table, use the deleteTHead() method.

Syntax

tableObject.createTHead()

Browser Support

All major browsers support the createTHead() method.

Example

Example

Create and delete thead elements:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>(.com)</title>
<script>
function createTHead(){
    var x=document.getElementById("myTable");
    if (!x.tHead){
    var header=x.createTHead();
    var row=header.insertRow(0);
    var cell=row.insertCell(0);
    cell.innerHTML="<b>This is a table header</b>";
    }
}
function deleteTHead(){
    document.getElementById("myTable").deleteTHead();
}
</script>
</head>
<body>

<table id="myTable" border="1">
    <tr>
        <td>cell 1</td>
        <td>cell 2</td>
    </tr>
    <tr>
        <td>cell 3</td>
        <td>cell 4</td>
    </tr>
</table>
<br>
<button type="button" onclick="createTHead()">Create Header</button>
<button type="button" onclick="deleteTHead()">Delete Header</button>

</body>
</html>
    

Try it yourself »

Table Object

HTML DOM Style Object

HTML DOM td / th Object

ByteArk Coding Plan

Supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax, with official direct supply, stable and reliable.

Configuration Guide

¥9.9 / month Activate Now

iFlytek Xingchen Coding Plan

Includes free model call quotas, DeepSeek, GLM, Kimi, MiniMax, a one-stop experience and deployment platform.

Configuration Guide

¥3.9 / month Activate Now

Click me to share notes

Category Navigation

Advertisement

Overview

Overview

  • JavaScript Objects
  • JavaScript Array Object
  • JavaScript Boolean Object
  • JavaScript Date Object
  • JavaScript Math Object
  • JavaScript Number Object
  • JavaScript String Object
  • JavaScript RegExp Object
  • JavaScript Global Properties/Functions
  • JavaScript Operators
  • JavaScript Error
  • Browser Objects
  • Window Object
  • Navigator Object
  • Screen Object
  • History Object
  • Location Object
  • Storage Objects
  • DOM Objects
  • HTML DOM Document Object
  • HTML DOM Element Object
  • HTML DOM Attribute Object
  • HTML DOM Event Object
  • HTML DOM Console Object
  • CSSStyleDeclaration Object
  • DOM HTMLCollection
  • HTML Objects
  • Online Examples
  • ·HTML Examples
  • ·CSS Examples
  • ·JavaScript Examples
  • ·Ajax Examples
  • ·jQuery Examples
  • ·XML Examples
  • ·Java Examples
  • Character Set & Tools
  • · HTML Character Set
  • · HTML ASCII Character Set
  • · JS Obfuscation/Encryption
  • · PNG/JPEG Image Compression
  • · HTML Color Picker
  • · JSON Formatting Tool
  • · Random Number Generator
  • Latest Updates
  • · AI Agent
  • · AI Evaluation and Security Research
  • · AI System Architecture
  • · Cutting-edge Research Trends
  • · NLP Advanced Techniques
  • · Computer Vision AI
  • · Deep Learning Basics
  • Site Information
  • · Feedback
  • · Disclaimer
  • · About Us
  • · Article Archive
  • Follow WeChat

My Favorites

← Htmldom ModifyEvent Onmouseover →