Reputation: 1877
I want to change the "Yes! Pick me" into "Picked" with Jquery in the following HTML structure. How should I select it? Please shed some light, thanks!
I tried $('#myDiv>table>tr').eq(1) but don't know how to continue...
<div id="myDiv">
<table>
<tr>
<td>Not me..</td>
<td>Not me..</td>
</tr>
<tr>
<td>Not me..</td>
<td>Yes! Pick me~ </td>
</tr>
</table>
</div>
Upvotes: 0
Views: 1149
Reputation: 8020
It's simple, just add a class to your td that you want to change like this:
<td class="to-change">Yes! Pick me~</td>
And jquery
$("td.to-change").html("Picked!");
Upvotes: 0
Reputation: 236182
Use the :contains
selector.
$('#myDiv').find('td:contains(Yes! Pick me~ )').text('Picked');
If you can't query for the contained text, do it like
$('#myDiv tr:eq1(1) td:last').text('Picked');
Upvotes: 1
Reputation: 253486
You could use:
$('td:contains("Yes! Pick me~ ")');
Or:
$('tr:eq(1) td:eq(1)');
References:
Upvotes: 1