1$( "li" ).each(function( index ) {
2 console.log( index + ": " + $( this ).text() );
3});
1//looping through list elements in jquery
2$('#myUlID li').each(function() {
3 console.log($(this));
4})
1$( "li" ).each(function( index ) {
2 console.log( index + ": " + $( this ).text() );
3});
4
1//Array
2$.each( arr, function( index, value ){
3 sum += value;
4});
5
6//Object
7$.each( obj, function( key, value ) {
8 sum += value;
9});
1// OBJECTS
2const obj = {
3 one: 1,
4 two: 2,
5 three: 3,
6 four: 4,
7 five: 5
8};
9
10$.each(obj, function(key, value) {
11 console.log(value);
12});
13
14// Outputs: 1 2 3 4 5
15
1$('.testimonial').each(function(){
2 //if statement here
3 // use $(this) to reference the current div in the loop
4 //you can try something like...
5 if(condition){
6 }
7 });