Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy don't I get the value from the text-node as I pass through the DOM tree?
    primarykey
    data
    text
    <p>In the following script I attempt to move through the <em>DOM Tree</em> but I do not get the output I expect.</p> <p>There is only a small piece of <em>html</em> in this :</p> <pre><code>&lt;p id="para"&gt;This is inside the &lt;em&gt;p&lt;/em&gt; tag.&lt;/p&gt; </code></pre> <p>As I move through the tree this is what I get :</p> <pre><code>Node Name : P Node Type : 1 Node Value : null Node Name : HTML Node Type : 1 Node Value : null </code></pre> <hr> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;JavaScript&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p id="para"&gt;This is inside the &lt;em&gt;p&lt;/em&gt; tag.&lt;/p&gt; &lt;script type="text/javascript"&gt; function nodeStatus(node) { document.write("Node Name : " + node.nodeName + "&lt;br /&gt;"); document.write("Node Type : " + node.nodeType + "&lt;br / &gt;"); document.write("Node Value : " + node.nodeValue + "&lt;br / &gt;"); document.write("&lt;br / &gt; &lt;br / &gt;"); } var curElement = document.getElementById("para"); nodeStatus(curElement); // p tag curElement = document.firstChild; // This is inside the nodeStatus(curElement); curElement = document.nextSibling; // em tag nodeStatus(curElement); curElement = document.firstChild; // p nodeStatus(curElement); &lt;/script&gt; &lt;/body&gt; </code></pre> <p></p> <p>Why don't I get the value from the <code>text-node</code> ? </p> <p>And what is that <em><strong>HTML</strong></em> that I get as a node name ? I haven't named any node as <em>HTML</em>.</p> <p>jsFiddle: <a href="http://jsfiddle.net/HmkJQ/" rel="nofollow">http://jsfiddle.net/HmkJQ/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload