dsf4s5787 2017-01-24 20:36
浏览 175
已采纳

如何获取nodes [i] .dataset.key的值

I have variable called Votes. And its looped like a list view.I want to update a specific raw item value of this varible.For that I use raw number here hard coded 765, and managed to get in. How can i get the value nodes[i].dataset.key and increment it

eg: My raw id 765 --> $varible value is 30 --> make it 31

    if (nodes[i].dataset.key == 765){
       // i want to go inside using raw ID and update the value display on that raw 
        }

Requirement:

I have varibale numVotes in a loop with values. In raw 765 i want to update that value. I already figured to find the exact raw now how to update the varibale value in that raw?

Update:

<td align="center" colspan="5" class="num_votes" data-key="<?php echo $rawID ?>"><?php echo $votes ?></td>

This is what i'm targeting. this is inside a raw.Now if this is raw 765 i want to update the vale $votes of that particular raw !

  • 写回答

1条回答 默认 最新

  • dongtu7567 2017-01-24 20:45
    关注

    Get the text content, parse the value, add 1 with the parsed value and re-assign the value.

    nodes[i].textContent = Number(nodes[i].textContent) + 1;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部