I have a web page I'm scraping, and the text I'm looking for is inside a span
that contains another span
<div class="someParentDiv">
<span>this is the text I want
<span class="childSpanClass">I don't want this text</span>
</span>
</div>
I'm trying to get the text I want with a jQuery selection, but when I get the elemnt's text with text()
, I will get also the child span's text, which I don't want.
I managed to get only the text I want with
$('div.someParentDiv span').remove('.childSpanClass')
but it seems a little backwards to me (see example), and I'm wondering if there's a better, nicer way to do it. Any ideas?