请您看一下这个演示,让我知道为什么我无法将article
对象的数据加载到表格行?
var article = {
student: 'Eve Jackson',
studentID: 'A0088888',
articles:[[
{title : "OOP Concepts", size : "Medium", printable:true}, {tags : ["C#", "Java", "Objective-c"]}, {weight : [1, 2, 1]}, 16, {extra : [0, 1.5, 0]}
] ,
[
{title : "Functional", size : "Large", printable:false}, {tags : ["JavaScript", "HTML", "PHP"]}, {weight : [2, 2, 1]}, 16, {extra : [0, 1.5, 0]}
] ,
[
{title : "Web", size : "Small", printable:true}, {tags : ["HTML", "CSS", "Angular","jQuery"]}, {weight : [3, 2, 1]}, 16, {extra : [0, 1.5, 0]}
]
]
};
for (i = 0; i < article.articles.length; i++) {
$('#map').append('<tr><td>'+ article.articles[i][0].title+'</td></tr>');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="width:100%">
<tr>
<th>Topic</th>
<th>Size</th>
<th>Printable</th>
<th>Tags</th>
</tr>
<tbody id="map"></tbody>
</table>
答案 0 :(得分:1)
将article.articles[0][i].title
更改为article.articles[i][0].title
答案 1 :(得分:0)
因为无法循环进入你的代码,所以
splice