In jQuery, you can use the $.each() method to loop through a collection of elements or objects. In vanilla JavaScript, you can achieve the same functionality using the forEach() method, which is available on arrays.
Source code viewer
const elements = document.querySelectorAll('.my-class'); elements.forEach(function(element) { // Do something with each element });Programming Language: ECMAScript