Create a Figcaption Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Figcaption


You can create a <figcaption> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">create a FIGCAPTION element with some text</button><br><br>

<figure id="myFigure">
  <img src="" alt="alt message" width="300" height="200">
</figure>/*from w  w  w.j  a v  a  2 s .co  m*/

function myFunction() {
    var x = document.createElement("FIGCAPTION");
    var t = document.createTextNode("Fig.1 - an image.");
    var y = document.getElementById("myFigure");


Related Tutorials