title: Differences between .text() and .html() with escaped < and > characters
body: <p>Given the following HTML fragment:</p>
  
  <pre><code>&lt;p id="para"&gt;hello &amp;lt;world&amp;gt;&lt;/p&gt;
  </code></pre>
  
  <p>The jQuery <a href="http://api.jquery.com/text/" rel="noreferrer"><code>.text()</code></a> and <a href="http://api.jquery.com/html/" rel="noreferrer"><code>.html()</code></a> methods will return different values...</p>
  
  <pre><code>var text = $('#para').text(); // gives 'hello &lt;world&gt;'
  var html = $('#para').html(); // gives 'hello &amp;lt;world&amp;gt;'
  </code></pre>
  
  <p>The jQuery documentation states</p>
  
  <blockquote>
    <p>The result of the <code>.text()</code> method is a string containing the combined text of all matched elements.</p>
  </blockquote>
  
  <p>and...</p>
  
  <blockquote>
    <p>In an HTML document, we can use <code>.html()</code> to get the contents of any element. If the selector expression matches more than one element, only the first one's HTML content is returned.</p>
  </blockquote>
  
  <p>But this specific difference with <code>&amp;lt;</code> and <code>&amp;gt;</code> doesn't seem to be documented anywhere.</p>
  
  <p>Can anyone comment on the rationale for this difference?</p>
  
  <h2>Edit</h2>
  
  <p>A little more investigation suggests that the values <code>.text()</code> and <code>.html()</code> match those from the native JavaScript <code>innerText</code> and <code>innerHTML</code> calls respectively (when the jQuery selector has returned a single element, at least). Again, this is not reflected in the jQuery documentation so I am not 100% sure if this observation holds true in all scenarios. Reading through the <a href="http://code.jquery.com/jquery-1.4.4.js" rel="noreferrer">jQuery source</a> reveals that this isn't what's actually going on under the hood.</p>