0
我有问题要加载我的JSON数据在我的表的标题。在我的功能loadJSON我在加载对象的评论是这样的:加载JSON数据标题中的表
<tr title="this['achievementlist'][i].comment"></tr>
导致: link of picture
当我删除”的评论被加载,但只。第一个字 看完后:HTML title attribute in Rails displaying only first word 我加了“回来了。从逻辑上这再次导致link of picture。
我该如何加载对象'achievementlist'的JSON评论作为标题?
的JSON数据:
{
"gijs":[
{
"name": "gijs",
"walletpoints": "5",
"totalpoints": "5",
"achievementlist":[
{
"achievementname": "een comaan",
"points": "50",
"comment": "werkt voor geen meter en ziet er niet uit"
},
{
"achievementname": "meer dan 5 huisdieren",
"points": "40",
"comment": "allemaal muizen in de kelder"
}
}
我所有的HTML代码:
<table>
<tr>
<td class="achievements"></td>
<script>
$.getJSON("../json/package.json", function (data)
{
$.each(data.gijs, function()
{
for (var i=0; i<this['achievementlist'].length; i++)
{
$(".achievements").append("<tr title="+"this['achievementlist'][i].comment" +" class='tablerow'><td class='JSONDATA'><div class='JSONName'>" + this['achievementlist'][i].achievementname + "</div><div class='JSONPoints'>Points: " + "<strong>"+this['achievementlist'][i].points+"</strong>" + "</div></td></tr>");
}
});
});
</script>
</tr>
</table>
只是为了确认,你想加载实际的评论到标题属性? –
是的,在我的问题中,有一条评论是:“如果我把鼠标悬停在表格数据上,我想阅读:”这就是我所说的“。 –