In the first, I create a block. The second is to remove it. However, for some reason it does not delete, although in other cases everything works. Those. when I make append with loading the page via php, everything is ok. And if I add using ajax, then the deletion is no longer applied to it. How can I fix it?
$(document).ready(function(){ $('#sub').click(function() { $.ajax({ url: "../register/writes/wall_support.php", type: "POST", dataType: "text", data: {write: $('#textarea').val(), button: $('#sub').val()}, success: function(data) { var arr = data.split('^'); var app = '<div value="'+arr[3]+'" class="read"><img src="../img/support.png" align="left"> <div class="united"><span style="color: #3333FF;">Поддержка <button class="deletewrite" value="'+arr[3]+'" title="Удалить"></button></span><br/><div style="width: 95%;">'+arr[0]+'</div><span style="color: #515151; font-size: 0.8em; font-family: Arial, sans-serif;">Опубликовал '+arr[1]+' администратор '+arr[2]+'</span></div></div>'; $(app).insertAfter("#after"); $('#textarea').val(''); $('#allwrites').text('Всего '+arr[4]+' записей'); } }) }); $('.deletewrite').click(function() { var value = $(this).val(); $.ajax({ url: "../register/writes/wall_support.php", type: "POST", dataType: "text", data: {number: value}, success: function(data) { $(this).parents('.read').remove(); $('#allwrites').text('Всего'+data+' записей'); } }) }); });