0
如果通過我的HTML表格中的所有單元格我環路和各rowOBj添加在tableOBJ一個新的屬性,它看起來像下面這樣BUT ....遍歷表以JSON
var tableOBJ = {};
$("table tr").each(function (index, value) {
var r = new rowOBJ(
$(this).find('td').eq(0).text(),
$(this).find('td').eq(1).text()
);
tableOBJ[index] = r;
});
var p = JSON.stringify(tableOBJ);
p =
{
"0":{"name":"fdgd","surname":"ssdt"},
"1":{"name":"fdsf","surname":"vn"},
"2":{"name":"dfsb","surname":"mry"},
"3":{"name":"hsdsdfry","surname":"smh"}
}
怎麼辦我做以前的樣子使json看起來像這樣
{
{"name":"fdgd","surname":"ssdt"},
{"name":"fdsf","surname":"vn"},
{"name":"dfsb","surname":"mry"},
{"name":"hsdsdfry","surname":"smh"}
}
你不會的,因爲你要的是不是有效的JSON。 – cdhowie 2012-08-01 19:19:23