使用jQuery循环遍历多维数组

3
我从一个PHP函数中得到了以下的返回数据:
data[0]
     [0]
       <table>
        ....
       </table>
     [1]
       <table>
        ....
       </table>
       .
       .
       .etc
 data[1]

如何使用 JavaScript 循环遍历此数组!

1
你尝试了什么?请解释数组和HTML的混合,数据类型是什么? - charlietfl
1个回答

5
可以使用嵌套的jQuery foreach函数。(点击此处查看文档)
$.each(data, function(key, value) { 
  //this is each data... data[0], data[1]... etc, the value being value and the index being key.
  $.each(key, function(innerKey, innerValue){
    //this is where your tables are. innerKey being the index innerValue being the value.
    <table>
    ...
    </table>
  });
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接