Why am I losing my characters from my html string when trying to add html dynamically using javascript
<p>I have a page that I am trying to dynamically add some links to. The links are getting added to the page fine, but the '[' and ']' at either end of the line are getting dropped. The code from my .js file is:</p>

<pre><code>var html = "[ &lt;a href='#'&gt;Change&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a href='#'&gt;Remove &lt;/a&gt; ]";
$(html).appendTo("#id123");
</code></pre>

<p>The result I want is:</p>

<pre><code>[ &lt;a href='#'&gt;Change&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a href='#'&gt;Remove&lt;/a&gt; ]
</code></pre>

<p>The result I'm getting is:</p>

<pre><code>&lt;a href='#'&gt;Change&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a href='#'&gt;Remove&lt;/a&gt;
</code></pre>

<p>If I wrap the line in a <code>&lt;span&gt;</code> tag like so:</p>

<pre><code>var html = "&lt;span&gt;[ &lt;a href='#'&gt;Change&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a href='#'&gt;Remove &lt;/a&gt; ]&lt;/span&gt;";
$(html).appendTo("#id123");
</code></pre>

<p>it renders as expected. I set a breakpoint on the code and checked the html var right before the .appendTo and it contains the '[' and ']'.</p>

<p>Anyone know why this is happening? Are '[' and ']' special character that need escaped and I'm just forgetting that fact?</p>
