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

deleteCaption method (table)

Browser support:
Removes the first caption element from the current table.
If no caption exists on the current table, the deleteCaption method has no effect. Note: a table element may have more than one caption in Internet Explorer and Opera, and at most one caption in Firefox, Google Chrome and Safari.
To create a new caption for a table, use the createCaption method.

Syntax:

object.deleteCaption ( );
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 deleteCaption method:
<head>
    <script type="text/javascript">
        function RemoveCaption () {
            var table = document.getElementById ("myTable");
            table.deleteCaption ();
        }
    </script>
</head>
<body>
    <table id="myTable" border="1px">
        <caption>
            <b>Caption for the table.</b>
        </caption>
        <tbody>
            <tr>
                <td>This text is inside the table.</td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <button onclick="RemoveCaption ();">Remove the caption!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content