I want to use JavaScript
/JQuery
to modify the text of an HTMLElement without affecting the child HTMLElements.
I have html that looks like:
<span class="js-my-parent-span">
"Hello, World!"
<span class="js-my-child-span">
</span>
</span>
I have attemted to change the Hello, World!
text using the innerHTML
and innerText
attributes as well as the html()
method from JQuery
. All of these methods also overwrite
the child span.
I just want to update the text.