title: Equivalent of innerHTML for text
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5023432/how-does-jquerys-text-work-internally">How does jQuery’s .text() work, internally?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm looking for the text equivalent of <code>innerHTML</code>, i.e.</p>
  
  <pre><code>&lt;p&gt;Hello, &lt;i&gt;World!&lt;/i&gt;&lt;/p&gt;
  </code></pre>
  
  <p>then <code>innerText(p)</code> should return <code>Hello, World!</code>.</p>
  
  <p>Note: I'm aware of jQuery's <code>text()</code> function. I want to know how it is implemented so I can do special handling on some nodes, like inserting extra white space.</p>