如何使用jQuery选择和更改表格单元格的值? [英] How to select and change value of table cell with jQuery?
本文介绍了如何使用jQuery选择和更改表格单元格的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用jQuery更改HTML示例中包含"c"字母的单元格的内容?
How do I change the content of the cell containing the 'c' letter in the HTML sample using jQuery?
<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");
也许为了重用,您可以创建一个调用函数
and maybe for reuse you could create a function to call
function ReplaceCellContent(find, replace)
{
$("#table_headers td:contains('" + find + "')").html(replace);
}
这篇关于如何使用jQuery选择和更改表格单元格的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文