html code
<table border="0" class="commentbox">
<tr>
<td>Some Item text
</td>
</tr>
<tr>
<td>
<div id="<%:containerid %>"></div>
<input type="button" class='btnReply' id="<%:rid %>" value="Reply"/>
</td>
</tr>
<tr>
<td>
<div id="replytopost">
</div>
</td>
</tr>
</table>
jquery code
$(document).ready(function () {
$(".commentbox .btnSave").live("click", function () {
alert("hii");
var itemId = $(this).attr("id").split("-")[1]
var txt = $(this).parent().find(".txtCmnt").val();
alert(itemId + txt);
$.post("Handler/Topic.ashx", { reply: txt, id: itemId }, function (data) {
alert(data);
$("#replytopost").html(data);
//do whatever with the response
})
});
});
Whenever I click dynamically created button with class .btnSave ,response is printed but If I click second time response get replaced with new value.
When I click second time response must not override. Every time response must come in new div.
How to do this.
The
.html()function is intended to completely replace the contents of the element. If you want to add to it, use the.append()function instead.