So I have the following setup:
<div class='topDiv'>
SomeText
<span>ChildText</span>
OtherText
<span>ChildText</span>
DifferentText
</div>
How do I remove the text "sometext", "othertext" and "DifferentText" in javascript (not Jquery) without removing the child text. Setting the innerHTML = ""; removes the contents, using the Jquery .text() or JavaScript .textContent = ""; doesn't work either.
I had a look at the first answer below, but this would only return the first SomeText (what I'm really looking for is something that would remove or select all the text xin the topDiv without affecting the spans.
The text can't be hidden either, it has to be removed
Thanks for any help!