When I write a comment on my page, I generate an ajax to save the comment in the database, and the response is the comment in html, this same comment has similar tags to the next one.
<a href="#" action="delete">Borrar</a>
I have the action function in the .js file
$('a[action]').on('click',function(e){
e.preventDefault();
// Resto de la función...
});
The problem is that by entering the code in the html document that function does not work, forgive the redundancy.
I enter the code with a .append () in the success: function () of ajax
$.ajax({..., success:function(e){
$('#div').append(e.codigo);}});
How do I avoid having to reload the entire .js file?