jquery - dynamic element not being created
<p>I am trying to add another <code>&lt;a&gt;</code> element after <code>&lt;a id='link1'&gt;</code></p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;script src="js/jquery-1.6.4.js" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script type="text/javascript"&gt;
            $(document).ready(function () {
                var myHTML = "&lt;div id='test'&gt;";
                myHTML += "&lt;span&gt;&lt;a id='link1'&gt;link 1&lt;/a&gt;&lt;/span&gt;";
                $("a#link1").after("&lt;a id='link2'&gt;link 2&lt;/a&gt;");
                myHTML += "&lt;/div&gt;";
                $("div#insertHere").html(myHTML);
            });
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="insertHere"&gt;

        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>The output of the above should be</strong></p>

<pre><code>&lt;body&gt;
   &lt;div id="insertHere"&gt;
      &lt;div id="test"&gt;
         &lt;span&gt;
            &lt;a id="link1"&gt;link 1&lt;/a&gt;
            &lt;a id="link2"&gt;link 2&lt;/a&gt;
         &lt;/span&gt;
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/body&gt;
</code></pre>
