title: jQuery Escaping HTML from a Textarea
body: <p>I want to escape HTML tags to entity names, taking text from a <code>textarea</code> and putting the result in a second <code>textarea</code> such that:</p>
  
  <pre><code>&lt;mytag&gt;
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>&amp;lt;mytag&amp;gt;
  </code></pre>
  
  <p>I'm using <code>.html()</code> and <code>.text()</code> going back and forth OK. My problem is dealing with the <code>textarea</code> element, which acts a little different.</p>
  
  <p>It works fine if I first place the text into a div: </p>
  
  <pre><code>var htmlStr = $('#textareaInput').val(); //doesn't like .html() .text() ?
  $('#dummy').text(htmlStr); // an object to hold the text that supports .html() 
  $('#textareaOutput').val($('#dummy').html());
  </code></pre>
  
  <p>But I want to do something more straightforward like this:</p>
  
  <pre><code>var htmlStr = $('#textareaInput').val(); 
  $('#textareaOutput').val($(htmlStr).html());
  </code></pre>
  
  <p>I guess my problem is that I don't understand how to manipulate jQuery objects, like strings, without manipulating DOM elements -because right now I'm using a div because it has the <code>.html()</code> method.</p>
  
  <p>Any help would be fantastic!</p>
  
  <p>Thanks.</p>