jQuery not triggering .click function from a jQuery generated HTML tags : <p>I have a button on my document, upon clicking will generate certain html tags.</p>

<pre><code>&lt;a type="button" name="repbut" &gt;Reply&lt;/a&gt; //on button click

    &lt;script type="text/javascript"&gt; // this script will be executed
    $(document).ready(function(){
    $('a[name=repbut]').click(function(){
        var boxid=$(this).attr("id");   
        $("#"+boxid+"1").html('&lt;ul&gt;&lt;li&gt;&lt;div class="comment"&gt;&lt;div class="comment-content"&gt;&lt;div class="comment-meta-author"&gt;Post your reply&lt;/div&gt;&lt;br&gt;&lt;div class="comment-body"&gt;&lt;div class="form-group"&gt;&lt;label&gt;Message&lt;/label&gt;&lt;textarea id="reep" class="form-control" rows="2"&gt;&lt;/textarea&gt;&lt;br&gt;&lt;span id="'+boxid+'2"&gt;&lt;/span&gt;&lt;a type="button" name="repcom" id="test" value="'+boxid+'" class="btn btn-primary pull-right"&gt;Reply&lt;/a&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;');
    });
    });
    &lt;/script&gt;
</code></pre>

<p>The problem is when i click the generated button nothing happens, not even alert function.</p>

<pre><code>&lt;a type="button" name="repcom" id="test" class="btn btn-primary pull-right"&gt;

&lt;script type="text/javascript"&gt;
$('a[name=repcom]').click(function(){
        alert("yes"); // not triggered
        });
&lt;/script&gt;
</code></pre>

<p>Am i doing something wrong? i am new to jQuery.
Any help is appreciated.</p>
