1var arr = ['one','two','three','four','five'];
2$.each(arr, function(index, value){
3 console.log('The value at arr[' + index + '] is: ' + value);
4});
1$( "li" ).each(function( index ) {
2 console.log( index + ": " + $( this ).text() );
3});
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$('.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 });
1$( "li" ).each( function( index, element ){
2 console.log( $( this ).text() );
3});
4
5// Logs the following:
6// Link 1
7// Link 2
8// Link 3
9