You're trying to use append()
like document.write()
. That's a wrong approach. You should look at the DOM starting at your table
node and append nodes for each row and cell.
Basically a $('<tr>')
to create a row, followed by an table.append()
call to add it to the DOM. Likewise for the cells.
var items = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]];
var items_converted = [[1,4,7,10],[2,5,8,11],[3,6,9,12]];
var table = $('#table');
var row, cell;
for(var i=0; i<items_converted.length; i++){
row = $( '<tr />' );
table.append( row );
for(var j=0; j<items_converted[i].length; j++){
cell = $('<td>'+items_converted[i][j]+'</td>')
row.append( cell );
}
}