How to Count Elements with a Specific Class using Vanilla JS
Count your elements containing a certain class with pure vanilla JS. Simple and Fast Snippet to include in your projects.
Here is a small snippet to get you started // ✅ Count all elements with class of blue const countAll = document.querySelectorAll('.blue').length; console.log(countAll); // 👉️ 3 // ✅ Count only