I have a button on my document, upon clicking will generate certain html tags.
<a type="button" name="repbut" >Reply</a> //on button click
<script type="text/javascript"> // this script will be executed
$(document).ready(function(){
$('a[name=repbut]').click(function(){
var boxid=$(this).attr("id");
$("#"+boxid+"1").html('<ul><li><div class="comment"><div class="comment-content"><div class="comment-meta-author">Post your reply</div><br><div class="comment-body"><div class="form-group"><label>Message</label><textarea id="reep" class="form-control" rows="2"></textarea><br><span id="'+boxid+'2"></span><a type="button" name="repcom" id="test" value="'+boxid+'" class="btn btn-primary pull-right">Reply</a></div><br></div></div></div></li></ul>');
});
});
</script>
The problem is when i click the generated button nothing happens, not even alert function.
<a type="button" name="repcom" id="test" class="btn btn-primary pull-right">
<script type="text/javascript">
$('a[name=repcom]').click(function(){
alert("yes"); // not triggered
});
</script>
Am i doing something wrong? i am new to jQuery. Any help is appreciated.