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
Post a Comment