Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select and change value of table cell with jQuery?

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> 

Thanks.

like image 865
abenci Avatar asked Jan 19 '11 15:01

abenci


1 Answers

$("td:contains('c')").html("new"); 

or, more precisely $("#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); } 
like image 141
hunter Avatar answered Oct 20 '22 06:10

hunter