+ 6
I really do not understand what 3 1 3 has to do with the document and how we arrived at it. Can someone help me understand that, please?
"3 1 3" ??? đ
5 Answers
+ 9
The script is looping through the document counting nodes. Each time it finds one it writes its type. In this case, it has found three: the first and third one is of type text (3) (it's white-space, but it's treated as text). The second one is of type 'element' (1).
+ 2
OK thanks. This app is no longer explanatory enough. Cos it didn't even explain the node types and their values (like text = 3, and element = 1). And the document.body just contains
<p>Some text</p>
So where does the text come before the element and before another text again? I'm confused. Can you explain further please? I'll really appreciate it. Thanks.
+ 2
OK yeah! I just realized that the numbers by the left that look like serial numbers (S/No.) are actually the values of the nodeTypes. I just don't know where and what (element, followed by texts/whitespace, followed by element) that produces {3 1 3} in <p>Some text</p>. Anyway, Thanks a lot. You've been so helpful.
+ 1
Go back to that lesson and you"ll see a table listing all node types.
As I wrote, and it's also mentioned in this app, white space is treated as text and thus considered a node.
+ 1
ZinC, it would be great if we had the explanation step-by-step. Thanks a lot for your help and patience!