Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Finding Elements by Class or Tag</title> </head> <body> <div class="user">User 1</div> <div class="user">User 2</div> <div class="user">User 3</div> <script> const users = document.getElementsByClassName('user'); // Display the number of users document.body.insertAdjacentHTML('beforeend', `<p>Number of users: ${users.length}</p>`); </script> </body> </html>