I am using this code:
(function( $ ) { $.fn.textNodes = function(number) { var nodes = jQuery(this).contents().filter(function(){ return this.nodeType == 3; }); if(jQuery.isNumber(number)){ return nodes[number]; } return nodes; }; })( jQuery );
He used to capture text nodes from html
For instance:
<div> <span>Testing</span> What is this? </div>
I'm looking for What is this?
This works as I can do console.log and see the result in the console.
But when I try to use the result in the input field, it gives me: [object Text]
How can I use the result as a string value?
I tried toString (), but this gives the same result if I did not miss anything.
source share