【发布时间】:2010-11-11 14:35:45
【问题描述】:
我正在使用 C# 应用程序进行 MVC。我试图访问表中的整行并使用 jquery 更改每个单元格中的值。
json 调用成功后,我需要更改每个 td 中的值。
请对此提出建议
【问题讨论】:
标签: jquery html asp.net-mvc json
我正在使用 C# 应用程序进行 MVC。我试图访问表中的整行并使用 jquery 更改每个单元格中的值。
json 调用成功后,我需要更改每个 td 中的值。
请对此提出建议
【问题讨论】:
标签: jquery html asp.net-mvc json
假设您的表的“ID”是“myTable”。
$.getJSON('http://yourpageurl.com',
function(data)
{
//Let's say you want to modify all the cells in the first row.
$('#myTable tr:first td')
.each(
function()
{
//'this' represens the cell in the first row.
$(this).html('changing cell value');
}
);
//If you want to access all cells of all the rows, replace
//#myTable tr:first td with
//'#myTable td'
}
);
编辑:
如果你知道你的 tr 的 'id',你可以替换
'#myTable tr:first td' 选择器带有 '#' 将 替换为您的 TR id。
【讨论】: