Consider the following HTML, I want to change 'blah' to something else.
<span>
<img src="/i/f_spacer.gif" class="my_class">
blah
</span>
Considering $('.my_class').parent().text()
returns 'blah' and .html()
returns everything - I thought something like this would work
$('.my_class').parent().text('foo');
but it turns it into
<span>
foo
</span>
Do I need to include a span around 'blah', or can I use some sort of pseudo-class to identify this text?
Cheers
Simply use nextSibling.data
$('.my_class')[0].nextSibling.data = "foo";
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With