<html>
<head>
<meta charset = "utf-8">
</head>
<body>
<figure id = "img1" onload = "myFunction(this.id)">
<img src="image.jpg">
<figcaption>
описание фото
</figcaption>
</figure>
<script>
var figure = document.getElementById("img1")
alert([
figure.querySelector("img").getAttribute("src"),
figure.querySelector("figcaption").innerHTML
])
</script>
</body>
</html>