How to append/prepend/create a text node with jQuery
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/944436/escaping-text-with-jquery-append">Escaping text with jQuery append?</a>  </p>
</blockquote>



<p>My HTML is somewhat like this:</p>

<pre><code>&lt;div id="selector"&gt;Hello World&lt;/div&gt;
</code></pre>

<p>Now I'd like to append some text to this div. I know that I could simply use</p>

<pre><code>$('#selector').append(text);
</code></pre>

<p>but this wouldn't escape any special characters in <code>text</code>. Another way is to wrap the text in a span:</p>

<pre><code>$('#selector').append( $('&lt;span&gt;').text(text) );
</code></pre>

<p>But this is ugly, because it creates unnecessary markup. So my current solution is to manually create a TextNode:</p>

<pre><code>$('#selector').append( document.createTextNode(text) );
</code></pre>

<p>I was wondering whether there is any <em>jQuery-style</em> way to do this?</p>
