gpt4 book ai didi

javascript - 将数据从 JavaScript 对象加载到表中

转载 作者:行者123 更新时间:2023-12-03 03:21:58 25 4
gpt4 key购买 nike

我正在编写以下代码。为什么我无法将数据从 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>

最佳答案

article.articles[0][i].title更改为article.articles[i][0].title

关于javascript - 将数据从 JavaScript 对象加载到表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46533762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com