Table deleteCaption()Method

Table 对象参考手册Table Object

Definition and Usage

The deleteCaption() method is used to delete the caption element and its content from a table.

Tip:To create a new caption in a table, use thecreateCaption()method.

Syntax

tableObject.deleteCaption()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the deleteCaption() method


Examples

Examples

The following example deletes the caption of a table:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
    document.getElementById("myTable").deleteCaption();
}
</script>
</head>
<body>

<table id="myTable" border="1">
<caption>This is a table caption</caption>
    <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="displayResult()">Delete Caption</button>

</body>
</html>

Try it Yourself »


Table 对象参考手册Table Object Other Extensions