Reputation: 6474
Consider the snippet of HTML for a web page given below--
<div id="divText">Text 1
<div id="divText1_1">Text 1_1</div>
<div id="divText1_2">Text 1_2</div>
<div id="divText1_3">Text 1_3</div>
<div id="divText1_4">Text 1_4</div>
</div>
Now, if a user has selected the first 2 divs within the outer div (i.e. "Text 1_1" and "Text 1_2"), then there are nodes corresponding to the 2 divs -i.e. divText1_1 and divText1_2, also there are 2 text nodes for the 2 text snippets selected by the user.
However, in addition to these nodes (2 text and 2 divs ) there is also one more text node, that occurs before the second div node. From what I understand, because there are spaces after the end of first inner div and before the second outer div, this space is also considered as a text node by the browser.
What I want to know is, how do I filter out such nodes? In other words, what are all the possible values for such text nodes? null/ ""/ " "/ other values? I would like to know all possible values so that I can correctly filter out such nodes
Upvotes: 1
Views: 48
Reputation: 816272
Text nodes always have a string as their value. If you want to filter out text nodes only containing white space characters, then you can trim the value and compare it against the empty string.
Upvotes: 1