How to work with document.images in JavaScript?

HTMLJavascriptProgramming Scripts

Use the document.images property in JavaScript to get the number of <img> tags in a document.

Example

You can try to run the following code to implement document.images property in JavaScript.

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>JavaScript Example</title>
   </head>
   <body>
      <h1>TutorialsPoint Tutorials</h1>
      <img src="/javascript/images/javascript-mini-logo.jpg"/><br>
      <img src="/html5/images/html5-mini-logo.jpg"/>
      <script>
         var num = document.images.length;
         document.write("<br>How many images? "+num);
      </script>
   </body>
</html>
raja
Updated on 20-May-2020 11:00:53

Advertisements