Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a FIGCAPTION element with some text.</p>
<button onclick="myFunction()">Try it</button><br><br>
<figure id="myFigure">
  <img src="../tags/img_pulpit.jpg" alt="The Pulpit Rock" width="304" height="228">
</figure>
<script>
function myFunction() {
  var x = document.createElement("FIGCAPTION");
  var t = document.createTextNode("Fig.1 - A view of the pulpit rock in Norway.");
  x.appendChild(t);
 
  var y = document.getElementById("myFigure");
  y.appendChild(x);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_figcaption_create by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:46:44 GMT -->
</html>