Possible Duplicate:
How do I select text nodes with jQuery?
In jquery we can select an element using:
$(#elem).get();
is their a way to select all text nodes of an element using jquery ?
Possible Duplicate:
How do I select text nodes with jQuery?
In jquery we can select an element using:
$(#elem).get();
is their a way to select all text nodes of an element using jquery ?
Try this,
$('#elem *').contents().filter(function() {
return (this.nodeType == 3);
});
This is the same question
try this:
$(elem)
.contents()
.filter(function() {
return this.nodeType === 3; //Node.TEXT_NODE
});
You can use .text() to get the text of an element, but I don't know if this will do exactly what you want. It's not clear from your question, but are you looking for something which would match only text nodes in the same way you can in XSLT? For example, a snippet like this:
<p>This is <strong>a typical</strong> line of <em>text</em>
Would result in 4 matched text nodes in XSLT. Is this what you meant?