Reputation: 5492
I want to replace content of a td
having certain text in a table.
Here is the table structure I am working with.
<table id="quotes" width="100%" cellspacing="0" cellpadding="2">
<tbody>
<tr class="rowEven">
<td>Store Pickup Store Pickup</td> <!-- td content to be replaced by "hello" -->
<td class="cartTotalDisplay">$0.00</td>
</tr>
</tbody>
</table>
I want to replace the above mentioned content with "hello"
Upvotes: 3
Views: 2050
Reputation: 15555
$('#quotes tbody tr').find("td:contains('Store Pickup Store Pickup')").text('hello');
Use :contains()
Description: Select all elements that contain the specified text.
Upvotes: 2
Reputation: 115222
You can use :contains()
selector for that
$("td:contains('Store Pickup Store Pickup')").text('hello');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="quotes" width="100%" cellspacing="0" cellpadding="2">
<tbody>
<tr class="rowEven">
<td>Store Pickup Store Pickup</td>
<td class="cartTotalDisplay">$0.00</td>
</tr>
</tbody>
</table>
Upvotes: 3