jQuery to loop through elements with the same class
javascript, jquery, jquery-selectors
Solution
Use each: '`i`' is the postion in the array, `obj` is the DOM object that you are iterating (can be accessed through the jQuery wrapper `$(this)` as well).
$('.testimonial').each(function(i, obj) {
//test
});
Check the api reference for more information.
Problem
I have a load of divs with the class `testimonial` and I want to use jquery to loop through them to check for each div if a specific condition is true. If it is true, it should perform an action. Does anyone know how I would do this?