我很困惑如何循环显示这个,以显示所有名称?
var x = [
{ "name":[{"value":"John"}] },
{ "name":[{"value":"Sam"}] },
{ "name":[{"value":"Michael"}] }
]
例如,如下所示,但如何访问数组?
var a = ["a", "b", "c"];
a.forEach(function(entry) {
console.log(entry);
});
答案 0 :(得分:1)
var x = [
{ "name":[{"value":"John"}] },
{ "name":[{"value":"Sam"}] },
{ "name":[{"value":"Michael"}] }
];
for (var i = 0; i < x.length; i++)
$(".output").append($("<div/>").text(x[i].name[0].value));