Iterating jquery each loop for two arrays at once

后端 未结 4 1502
感动是毒
感动是毒 2020-12-10 14:30

I have two Javascript arrays of same size

var demo=new Array();
var demo3=new Array();

I need to access the value of the two array in one e

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 15:03

    Try using .concat if you want to joint iterate..

    $.each(demo.concat(demo3), function (idx, el) {
         alert(el);
    });
    

    else simply iterate the array and use the index to access next..

    $.each(demo, function (idx, el) {
         alert(el);
         alert(demo3[idx]);
    });
    

提交回复
热议问题