AlecPerkey
AlecPerkey

Reputation: 657

JQuery selector for free floating text node

How would one select only the 'foo' text (and not the span) in this example?

<div class="bar">foo
    <span>...</span>
</div>

Alternatively, what would your search query to figure this out be? I'm at a loss...

Upvotes: 0

Views: 84

Answers (1)

AlecPerkey
AlecPerkey

Reputation: 657

With JQuery & cheerio, it seems one can use :

$('div.bar').contents()[0]

src: How do I select text nodes with jQuery?

Upvotes: 1

Related Questions