Answer the question
In order to leave comments, you need to log in
How to get text from container but not include children?
Markup like this:
<p>
<s>2</s>
1
</p>
Answer the question
In order to leave comments, you need to log in
On pure js:
var p = document.getElementsByTagName('p')[0],
text = '',
child,
index;
for (index = 0; index < p.childNodes.length; index++) {
child = p.childNodes[index];
if (child.nodeType == Node.TEXT_NODE)
{
text += child.nodeValue;
}
}
console.log(text);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question