I'd like to update element's text dynamically:
<div>
**text to change**
<someChild>
text that should not change
</someChild>
<someChild>
text that should not change
</someChild>
</div>
I'm new to jQuery, so this task seems to be quite challenging for me. Could someone point me to a function/selector to use?
If it is possible, I'd like to do it without adding a new container for the text I need to change.
Lots of great answers here but they only handle one text node with children. In my case I needed to operate on all text nodes and ignore html children BUT PRESERVE THE ORDERING.
So if we have a case like this:
We can use the following code to modify the text only AND PRESERVE THE ORDERING
Here is the jsfiddle of it working