document.getElementByTagName() enables you to find objects based in tag name like img, a, ...
Below example shows how to find image objects in the HTML page:
const images = document.getElementsByTagName('img'); for (let i = 0; i < images.length; i++) { console.log(images[i].src); }
If you want to filter by some criteria, you can use the querySelectorAll() method instead:
const images = document.querySelectorAll('img.my-class'); for (let i = 0; i < images.length; i++) { console.log(images[i].src); }