You are here: Reference > JavaScript > client-side > HTML DOM > methods > deleteTHead (table)

deleteTHead method (table)

Browser support:
Removes the thead element from the table.
If no thead exists on the current table, the deleteTHead method has no effect.
To create a new header for a table, use the createTHead method.

Syntax:

object.deleteTHead ( );
You can find the related objects in the Supported by objects section below.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the createTHead and deleteTHead methods:
<head>
    <script type="text/javascript">
        function CreateHeader () {
            var table = document.getElementById ("myTable");
            if (!table.tHead) {
                var header = table.createTHead ();
                var row = header.insertRow (0);
                var cell = row.insertCell (0);
                cell.innerHTML = "<b>Header for the table.</b>";
            }
        }
        function RemoveHeader () {
            var table = document.getElementById ("myTable");
            table.deleteTHead ();
        }
    </script>
</head>
<body>
    <table id="myTable" border="1px">
        <tbody>
            <tr>
                <td>This text is inside the table.</td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <button onclick="CreateHeader ();">Create a header for the table!</button>
    <button onclick="RemoveHeader ();">Remove the header from the table!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content