我使用nodejs句柄栏为每个表创建一个:
<tbody>
{{#each result}}
<tr>
<td id="engagementTotal">{{data.engagementTotal}}</td>
</tr>
{{/each}}
</tbody>
但我需要通过onclick函数更改每个值的值,我尝试使用
for (var i=0; i < positiveTotal.length; i++){
sEngagementTotal.push(positiveTotal[i].data.engagementTotal);
}
document.getElementById("engagementTotal").innerHTML = sEngagementTotal;
但上面只更改了第一个表格的值
答案 0 :(得分:1)
而不依赖于id依赖于类
<tbody>
{{#each result}}
<tr>
<td id="engagementTotal" class="demo">{{data.engagementTotal}}</td>
</tr>
{{/each}}
</tbody>
for (var i=0; i < positiveTotal.length; i++){
sEngagementTotal.push(positiveTotal[i].data.engagementTotal);
}
document.getElementByClass("demo").innerHTML = sEngagementTotal;