Quick Answers: How many images are in the DOM?

You can dynamically determine the number of images (<img>) on a web page by using Javascript.

var imgCount = document.getElementsByTagName('img').length

To create a reusable function you can use the following code:

function countAllImages()
{
var imgCount = document.getElementsByTagName('img').length;
return imgCount;
}

Leave a Reply