How to make an array of arrays like
{ [1,2,3],[2,3,4],[2,34,55] }
in jQuery ?
$(document).ready(function() {
var row = 4;
var items = [];
var total = [];
$('#test tr:eq(' + row + ') td').each(function(colindex, col) {
//alert(colindex);
t = $(this).contents();
items.length = 0;
$.each(t, function(i, val) {
if (val.tagName != 'BR') {
if (val.innerHTML == undefined) {
items.push(val.data);
}
else
items.push(val.innerHTML);
}
//alert(items.toString());
});
total.push(items);
});
alert(total.toString());
});
iIn the above code I'm trying to create a array Total() with the elements as arrays (item()), but how ever the Total() array has only one object that too the last item() array.
{ [1,2,3],[2,3,4],[2,34,55] }is an invalid object literal, not an object containing arrays (it doesn't have any property names). But yes, the correct notation for an array of arrays when written as a literal would indeed be[[1,2,3],[2,3,4],[2,34,55]].