Getting text nodes using jQuery
It just takes a little extra work to filter a node's contents based on their type:
$node.contents().filter(function() {
//Node.TEXT_NODE === 3
return (this.nodeType === 3);
}).each(function () {
// for each text node, do something with this.nodeValue
});
Fork the gist: https://gist.github.com/147952
Written by travis
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#