Get Caption Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Caption


The Caption object represents an HTML <caption> element.

You can access a <caption> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th, td {
    border: 1px solid black;
</style>/*  w w w  .j  a  v a2  s. com*/

  <caption id="myCaption">this is the caption</caption>

<button onclick="myFunction()">set the color of the caption to red</button>

function myFunction() {
    var x = document.getElementById("myCaption"); = "red"; = "1px blue solid";


Related Tutorials