Say i have this:
<div class='myDiv'>
<p>hello</p>
hello
<p>Hello</p>
</div>
How does one grab the text hello between the two P tags using jQuery?
$('.myDiv')
.contents()
.filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).text();
How do I select text nodes with jQuery?
http://jsfiddle.net/6us8r/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With