Javascript examples for DOM HTML Element:Caption
The Caption object represents an HTML <caption> element.
You can access a <caption> element by using getElementById():
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>/* w w w .j a v a2 s. com*/ </head> <body> <table> <caption id="myCaption">this is the caption</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table> <button onclick="myFunction()">set the color of the caption to red</button> <script> function myFunction() { var x = document.getElementById("myCaption"); x.style.color = "red"; x.style.border = "1px blue solid"; } </script> </body> </html>