我不明白如何增加表格单元格的值,例如: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/