使用对象数据填充元素类

时间:2016-03-21 20:52:10

标签: javascript html sharepoint-2013

我试图使用来自对象的数据填充几个lement类:

HTML:

$this->Order->OrderItem

使用Javascript:

 <table>
 <tr>
 <td><span class="hoursspan"></span></td>
 <td><span class="partspan"></span></td>
 </tr>
 <tr>
 <td><span class="hoursspan"></span></td>
 <td><span class="partspan"></span></td>
 </tr>
 <tr>
 <td><span class="hoursspan"></span></td>
 <td><span class="partspan"></span></td>
 </tr>
 <tr>
 <td><span class="hoursspan"></span></td>
 <td><span class="partspan"></span></td>
 </tr>
 </table>

它在fiddle中运行得很好,但在我的环境(SharePoint 2013 on Premises)中,我不断获得var finalData = [{ "issue": "A", "hours": 79, "partcipantes": 33 }, { "issue": "B", "hours": 16, "partcipantes": 10 }, { "issue": "C", "hours": 12, "partcipantes": 10 }, { "issue": "D", "hours": 5, "partcipantes": 8 }]; for (var w = 0; w < finalData.length; w++) { document.getElementsByClassName("hoursspan")[w].innerHTML = finalData[w].hours; document.getElementsByClassName("partspan")[w].innerHTML = finalData[w].partcipantes; } 。我不知道还有什么可以造成这个问题?

谢谢。

0 个答案:

没有答案