<html>
<body>
<p>Click the button to create a FIGURE element containing an IMG element.</p>
<button onclick="myFunction()">Try it</button><br><br>
<script>
function myFunction() {
var x = document.createElement("FIGURE");
x.setAttribute("id", "myFigure");
document.body.appendChild(x);
var y = document.createElement("IMG");
y.setAttribute("src", "img_pulpit.jpg");
y.setAttribute("width", "304");
y.setAttribute("width", "228");
y.setAttribute("alt", "The Pulpit Rock");
x.appendChild(y);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_figure_create by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:11:57 GMT -->
</html>