如何使用 jQuery 更改 HTML 示例中包含“c”字母的单元格内容?
<table id="table_header">
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
</table>
谢谢。
最佳答案
$("td:contains('c')").html("new");
或更准确地说$("#table_headers td:contains('c')").html("new");
也许为了重用,您可以创建一个函数来调用
function ReplaceCellContent(find, replace)
{
$("#table_headers td:contains('" + find + "')").html(replace);
}
关于jquery - 如何使用 jQuery 选择和更改表格单元格的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4737476/