<div>
some text I want
<span><sup>text I don't want</sup></span>
</div>
Above is some example html. I want to be able to select just the text of the div without the child html text that is located in the span. Is there any simple way of doing this or am I going to have to come up with some way to hack away at the markup?
I’ve tried using jquery selectors to select just the div but when I end up calling the .text() method you end up with all of the text again… Am I missing something extremely obvious?
May be something like below should get you the text,
DEMO
Note that this would also return you the line breaks and white space.
You can use
$.trimto get rid of those,