I have a mild preference in solving this in pure JS, but if the jQuery version is simpler, then jQuery is fine too. Effectively the situation is like this
<span id="thisone">
The info I want
<span id="notthisone">
I don't want any of this nonsense
</span>
</span>
I effectively want to get
The info I want
but not
The info I want I don't want any of this nonsense
and I especially don’t want
The info I want <span id="notthisone"> I don't want any of this nonsense </span>
which is unfortunately what I am getting right now…
How would I do this?
With js only:
Try it out: http://jsfiddle.net/g4tRn/
With jQuery:
Try it out: http://jsfiddle.net/g4tRn/1
Bonus:
If there are other text nodes in the outer
<span>that you want to get, you could do something like this:Try it out: http://jsfiddle.net/g4tRn/4