title: Escaping text with jQuery append?
body: <p>I know that I can use <code>$.html</code> to set the HTML content of something, and <code>$.text</code> to set the content (and that this escapes the HTML).</p>
  
  <p>Unfortunately, I'm using <code>$.append</code>, which doesn't escape the HTML.</p>
  
  <p>I've got something like this:</p>
  
  <pre><code>function onTimer() {
      $.getJSON(url, function(data) {
          $.each(data, function(i, item) {
             $('#messages').append(item);
          }
      }
  }
  </code></pre>
  
  <p>...where the url returns an array of strings. Unfortunately, if one of those strings is (e.g.) <code>&lt;script&gt;alert('Hello')&lt;/script&gt;</code>, this gets executed.</p>
  
  <p>How do I get it to escape HTML?</p>