<!DOCTYPE html>
<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>
</html>