Get Figcaption Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Figcaption


The Figcaption object represents an HTML <figcaption> element.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

  <img src="" alt="alt message" width="300" height="200">
  <figcaption id="myFigCap">Fig.1 - an image.</figcaption>
</figure>/*w ww .j  a  v a2  s .  c om*/

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

function myFunction() {
    var x = document.getElementById("myFigCap"); = "red";


Related Tutorials