jQuery change child text
You would simply change another element's text.
<td>
<a href="#">Link</a>
<span>SomeText</span>
</td>
Then invoke like so:
$('td').find('span').text('myNewText');
If you have:
<td class="v3">
<a href="somelink">text to change</a>
</td>
Then in your function you should have something like this:
$("td.v3").children("a").text("new text");
However, this will select all links that are direct children of td
s with class .v3
. Adding a .first()
after children should help:
$("td.v3").children("a").first().text("new text");
Wrap the text in a span
element, and change the text in the span.
<div id="foo">
<span>bar</span>
<a href="#">link</a>
</div>
...
$('#foo span').text('new text');
Edit:
Or use $('td.v3 a').text("new text")
to change the text in the anchor, if that's what you want to do.