javascript - JQuery foreach chunk 2 and 2 -


so have array:

mike blue jakob red luis orange 

executing jquery code:

$.each( arr, function( index, value ){      $( ".div" ).append( "" + value + "" );     }   }); 

i each loop
jump every second value. loop create like:

mike - blue jakob - red luis - orange 

can point me in right direction?

instead of using $.each, can use normal for loop , increment 2 instead of 1.

for(var = 0; < arr.length; += 2){     $(".div").append(arr[i] + ' - ' + arr[i+1]); } 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -