我有一个名为 Votes 的变量。它像 ListView 一样循环。我想更新这个变量的特定原始项目值。为此,我在这里使用硬编码的原始数字 765,并设法进入。我如何获得值 nodes[i ].dataset.key
并增加它
例如:我的原始 ID 765 --> $varible 值为 30 --> 设为 31
if (nodes[i].dataset.key == 765){
// i want to go inside using raw ID and update the value display on that raw
}
要求:
我在一个带有值的循环中有可变的 numVotes。在原始 765 中,我想更新该值。我现在已经想找到确切的原始数据,如何更新该原始数据中的变量值?
更新:
<td align="center" colspan="5" class="num_votes" data-key="<?php echo $rawID ?>"><?php echo $votes ?></td>
这就是我的目标。这是在原始内部。现在,如果这是原始 765,我想更新该特定原始的谷 $votes!
最佳答案
获取文本内容,解析值,将解析值加1
,重新赋值。
nodes[i].textContent = Number(nodes[i].textContent) + 1;
关于javascript - 如何获取nodes[i].dataset.key的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41843470/