2012-06-25 207 views
3

我有從PHP函數的返回的數據如下所示:循環通過多維陣列的jquery

data[0] 
    [0] 
     <table> 
     .... 
     </table> 
    [1] 
     <table> 
     .... 
     </table> 
     . 
     . 
     .etc 
data[1] 

我怎樣才能通過該陣列由JavaScript循環!

+1

你嘗試過什麼?請解釋數組和html的組合,數據類型究竟是什麼? – charlietfl

回答

5

這將有可能有一個嵌套jQuery foreach function.

$.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> 
    }); 
});