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
// JQUERY $('.my-class').each(function(index, element) { // Your code here }); // VANILLA JAVASCRIPT document.querySelectorAll('.my-class').forEach(function(element, index) { // Do something with each element });Programming Language: ECMAScript