我们说我有一个类似下面的JSON文件。如何将特定值(例如0.69)插入HTML页面?
{
"species":1,
"animal":[
{"day": 1,"weight": [0.69,1,2,3],"amounteaten": [22,16,15,14],"emergencies": [0,0,0,0]},
{"day": 2,"weight": [0.5,1,3,4],"amounteaten": [22,17,15,14],"emergencies": [0,0,1,0]}
]
}
答案 0 :(得分:4)
你在找这样的东西吗?
<div id="foo"></div>
$.getJSON('intro.json', function(obj) {
document.getElementById("foo").textContent = obj.animal[0].weight[0];
});