<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h3>A demonstration of how to access a CAPTION element</h3>
<table>
<caption id="myCaption">Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
<p>Click the button to set the color of the caption to red.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementById("myCaption");
x.style.color = "red";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_caption_get by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:05:24 GMT -->
</html>