gpt4 book ai didi

javascript - 如何增加表格单元格的值?

转载 作者:行者123 更新时间:2023-11-30 10:53:25 26 4
gpt4 key购买 nike

我不明白如何增加表格单元格的值,例如:1、2、3 等?

我的代码:

$('#table').each(function(i){
$(this).find('td:nth-child(1)').text(i);
});

请看full example .

最佳答案

我认为this是你想要的:

var i = 1;
$('#table').find('td:nth-child(1)').each(function()
{
$(this).text(i++);
});

simpler :

$('#table').find('td:nth-child(1)').each(function(i)
{
$(this).text(i + 1);
});

关于javascript - 如何增加表格单元格的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3940145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com