Here's one example of doing what you want.
var myTableArray = [];
$("table#cartGrid tr").each(function() {
var arrayOfThisRow = [];
var tableData = $(this).find('td');
if (tableData.length > 0) {
tableData.each(function() { arrayOfThisRow.push($(this).text()); });
myTableArray.push(arrayOfThisRow);
}
});
alert(myTableArray);
You could probably expand on this, say, using the text of the TH to instead create a key-value pair for each TD.
Since this implementation uses a multidimensional array, you can access a row and a td by doing something like this:
myTableArray[1][3] // Fourth td of the second tablerow
Edit: Here's a fiddle for your example: http://jsfiddle.net/PKB9j/1/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…