title: innerText/textContent vs. retrieving each text node
body: <p>I've heard that using <code>el.innerText||el.textContent</code> can yield unreliable results, and that's why I've always insisted on using the following function in the past:</p>
  
  <pre><code>function getText(node) {
  
      if (node.nodeType === 3) {
          return node.data;
      }
  
      var txt = '';
  
      if (node = node.firstChild) do {
          txt += getText(node);
      } while (node = node.nextSibling);
  
      return txt;
  
  }
  </code></pre>
  
  <p>This function goes through all nodes within an element and gathers the text of all text nodes, and text within descendants:</p>
  
  <p>E.g.</p>
  
  <pre><code>&lt;div id="x"&gt;foo &lt;em&gt;foo...&lt;/em&gt; foo&lt;/div&gt;
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>getText(document.getElementById('x')); // =&gt; "foo foo... foo"
  </code></pre>
  
  <p>I'm <em>quite</em> sure there are issues with using <code>innerText</code> and <code>textContent</code>, but I've not been able to find a definitive list anywhere and I am starting to wonder if it's just <em>hearsay</em>.</p>
  
  <p>Can anyone offer any information about the possibly lacking reliability of textContent/innerText?</p>
  
  <p><strong>EDIT</strong>: Found this great answer by Kangax -- <a href="https://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox/1359822#1359822">&#39;innerText&#39; works in IE, but not in Firefox</a></p>