
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return Number of Images in a Document with JavaScript
To return the number of images in a document, use the images property in JavaScript.
Example
You can try to run the following code to get the count of images −
<!DOCTYPE html> <html> <body> <img src="https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg"> <img src="https://www.tutorialspoint.com/hive/images/hive-mini-logo.jpg"> <img src="https://www.tutorialspoint.com/sas/images/sas-mini-logo.jpg"> <img src="https://www.tutorialspoint.com/maven/images/maven-mini-logo.jpg"> <script> var val = document.images.length; document.write("<br>Number of images in the document: "+val); </script> </body> </html>
Advertisements