How to find how many images are present in a current page

Manideepgoud
Posted by Manideepgoud under JavaScript category on | Points: 40 | Views : 140
We can find how many images are present in a current page by using document.images.length.

<img src="gauva.jpg" />
<img src="apple.jpg" />
<img src="gauva.jpg" />
<img src="apple.jpg" />
<p id="demo"></p>
<script>
document.getElementById('demo').innerHTML = "Number of images in the page are :" + document.images.length;
</script>
.
In the above code we have taken four images, document.images.length finds out how many images are present in the HTML page.

OUTPUT

Number of images in the HTML page are :4

Comments or Responses

Login to post response